Abstract class to represent the characteristics of a related model.


This class is part of the Solar_Sql_Model package.


Configuration Keys

  • wherein_max: The default value for the 'wherein_max' setting.



Public Properties

These are all the public properties in the Solar_Sql_Model_Related class.

You can also view the list of all public, protected, and private properties.


Fetch these columns for the related records.


Additional conditions when fetching related records.


Aliases the foreign table to this name.


The class name of the foreign model.


The name of the column to join with in the foreign table.


The virtual element called foreign_key automatically populates the native_col or foreign_col value for you, based on the association type.


The virtual element called foreign_name automatically sets the foreign_class by looking up the foreign_name in the model catalog.


The name of the foreign primary column.


The name of the table for the foreign model.


Indicates the strategy to use for merging joined rows; 'server' means the database will do it via a single SELECT combined into the native fetch, whereas 'client' means PHP will do it, using one additional SELECT for the relationship.


The name of the relationship as defined by the original (native) model.


The alias for the native table.


What strategy should be used for connecting to native records when eager-fetching: 'wherein', meaning a "WHERE IN (...)" a list of native IDs, or 'select', meaning a join against a sub-SELECT.


The class of the native model.


The native column to match against the foreign primary column.


Additional ORDER clauses when fetching related records.


The type of the relationship as defined by the original (native) model; e.g., 'has_one', 'belongs_to', 'has_many'.


When picking a native-by strategy, use 'wherein' for up to this many record in the native result; after this point, use a 'select' strategy.

Public Methods

These are all the public methods in the Solar_Sql_Model_Related class.

You can also view the list of all public, protected, and private methods.




Default destructor; does nothing other than provide a safe fallback for calls to parent::__destruct().


Convenience method for getting a dump the whole object, or one of its properties, or an external variable.


Fetches the related record or collection for a native ID or record.


Returns a new empty value appropriate for a lazy- or eager-fetch; this is different for each kind of related.


Fetches a new record or collection object.


Gets the foreign-model WHERE conditions and merges with the WHERE conditions on this relationship.


Returns the related (foreign) model instance.


Is the related record or collection valid?


Is this related to many records?


Is this related to one record?


Loads this relationship object with user-defined characteristics (options), and corrects them as needed.


Looks up class-specific locale strings based on a key.


Fixes the native fetch params and eager params; then, if the join_flag is set on the eager, calles _modEagerFetch() to modify the native fetch params based on the eager params.


Modifies the parent result array to add eager records.


Packages foreign data as a record or collection object.


Pre-save hook for saving related records or collections from a native record.


Saves a related record or collection from a native record.


Sets the native (origin) model instance.


Returns the relation characteristics as an array.