protected function _hasOneOrMany($associated_class_name, $foreign_key_name = null, $foreign_key_name_in_current_models_table = null, $connection_name = null)
        {
            $base_table_name = self::_getTableName(get_class($this));
            $foreign_key_name = self::_buildForeignKeyName($foreign_key_name, $base_table_name);

            $where_value = ''; //Value of foreign_table.{$foreign_key_name} we're
                               //looking for. Where foreign_table is the actual
                               //database table in the associated model.

            if(is_null($foreign_key_name_in_current_models_table)) {
                //Match foreign_table.{$foreign_key_name} with the value of
                //{$this->_table}.{$this->id()}
                $where_value = $this->id();
            } else {
                //Match foreign_table.{$foreign_key_name} with the value of
                //{$this->_table}.{$foreign_key_name_in_current_models_table}
                $where_value = $this->$foreign_key_name_in_current_models_table;
            }

            return self::factory($associated_class_name, $connection_name)->where($foreign_key_name, $where_value);
        }
protected function _hasOneOrMany($associated_class_name, $foreign_key_name = null, $foreign_key_name_in_current_models_table = null, $connection_name = null)
        {
            $base_table_name = self::_getTableName(get_class($this));
            $foreign_key_name = self::_buildForeignKeyName($foreign_key_name, $base_table_name);

            $where_value = ''; //Value of foreign_table.{$foreign_key_name} we're
                               //looking for. Where foreign_table is the actual
                               //database table in the associated model.

            if(is_null($foreign_key_name_in_current_models_table)) {
                //Match foreign_table.{$foreign_key_name} with the value of
                //{$this->_table}.{$this->id()}
                $where_value = $this->id();
            } else {
                //Match foreign_table.{$foreign_key_name} with the value of
                //{$this->_table}.{$foreign_key_name_in_current_models_table}
                $where_value = $this->$foreign_key_name_in_current_models_table;
            }

            return self::factory($associated_class_name, $connection_name)->where($foreign_key_name, $where_value);
        }
protected function _hasOneOrMany ( $ associated_class_name , $ foreign_key_name = null , $ foreign_key_name_in_current_models_table = null , $ connection_name = null ) { $ base_table_name = self :: _getTableName ( get_class ( $ this ) ) ; $ foreign_key_name = self :: _buildForeignKeyName ( $ foreign_key_name , $ base_table_name ) ; $ where_value = '' ; //Value of foreign_table.{$foreign_key_name} we're //looking for. Where foreign_table is the actual //database table in the associated model. if ( is_null ( $ foreign_key_name_in_current_models_table ) ) { //Match foreign_table.{$foreign_key_name} with the value of //{$this->_table}.{$this->id()} $ where_value = $ this -> id ( ) ; } else { //Match foreign_table.{$foreign_key_name} with the value of //{$this->_table}.{$foreign_key_name_in_current_models_table} $ where_value = $ this -> $ foreign_key_name_in_current_models_table ; } return self :: factory ( $ associated_class_name , $ connection_name ) -> where ( $ foreign_key_name , $ where_value ) ; }
Internal method to construct the queries for both the has_one and
has_many methods. These two types of association are identical; the
only difference is whether find_one or find_many is used to complete
the method chain.

@param  string      $associated_class_name
@param  null|string $foreign_key_name
@param  null|string $foreign_key_name_in_current_models_table
@param  null|string $connection_name
@return OneWrapper
Internal method to construct the queries for both the has_one and has_many methods . These two types of association are identical ; the only difference is whether find_one or find_many is used to complete the method chain .