|
pclib
3.2.0
Lightweight PHP framework
|
It represents related record(s) of the Model. More...
Public Member Functions | |
| __construct (Model $model, $name) | |
| Constructor. More... | |
| getJoinCondition () | |
| save ($record) | |
| Save $record as relation of the owner. More... | |
| clear () | |
| Clear selection query and data. More... | |
Public Member Functions inherited from Selection | |
| rewind () | |
| Iterator.rewind() implementation. | |
| current () | |
| Iterator.current() implementation. | |
| key () | |
| Iterator.key() implementation. | |
| next () | |
| Iterator.next() implementation. | |
| valid () | |
| Iterator.valid() implementation. | |
| __call ($name, $args) | |
| PHP magic method. More... | |
| first () | |
| Return first record in the selection. More... | |
| isEmpty () | |
| Is Selection empty? More... | |
| count () | |
| Return number of rows in the Selection. | |
| sum ($s) | |
| Return summary of field $s. More... | |
| avg ($s) | |
| Return AVG of field $s. More... | |
| find ($id) | |
| Find record by primary key. More... | |
| update (array $values) | |
| Update records in selection with $values. | |
| delete () | |
| Delete selection. | |
| getClone () | |
| Clone selection. | |
| limit ($limit, $offset=0) | |
| Set selection limit. More... | |
| select ($columns) | |
| Execute selection and return array of rows. More... | |
| selectPair ($columns) | |
| See Db->selectPair(). | |
| from ($s) | |
| Set source table $s. More... | |
| where ($s) | |
| Set where condition. More... | |
| whereJoin ($relName, $s) | |
| Set where condition. More... | |
| order ($s) | |
| Set order by clausule. More... | |
| group ($s) | |
| Set group by clausule. More... | |
| having ($s) | |
| Set having clausule. More... | |
| close () | |
| Closes the cursor, enabling the query to be executed again. More... | |
| getSql () | |
| Build sql query for current selection. More... | |
| toArray ($deep=false) | |
| Return current selection as array. More... | |
| __toString () | |
| Return string representation of selection for debugging purposes. | |
Public Member Functions inherited from BaseObject | |
| loadDefaults ($className=null) | |
| Load default parameters of class $className into object instance. | |
| setProperties (array $defaults) | |
| Set public properties of object from the array. More... | |
| toArray () | |
| Convert object to array. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from BaseObject | |
| static | defaults () |
| Set or retireve default parameters of the object. More... | |
Data Fields inherited from Selection | |
| $db | |
| var Db | |
Data Fields inherited from BaseObject | |
| $serviceLocator | |
| var function() Return service object when requested with service(). | |
Protected Member Functions inherited from Selection | |
| newModel ($data) | |
| Create model instance, fill its values with $data and return it. More... | |
| execute () | |
| Execute query to the database and set $this->result. More... | |
Protected Member Functions inherited from BaseObject | |
| service ($service, $default=null) | |
| Try acquire $service and load it into property $this->$service. More... | |
Protected Attributes inherited from Selection | |
| $query = array() | |
| Array of sql query clausules. | |
| $result = null | |
| Result of underlying sql query. | |
| $data = array() | |
| Data of the current row. | |
It represents related record(s) of the Model.
Usually you do not instantiate this class manually - it is returned by Model->related() method. Because it is Selection, you can use where(), order() etc. methods on related records. Examples:
| __construct | ( | Model | $model, |
| $name | |||
| ) |
Constructor.
| Model | $model | Owner of the relation |
| string | $name | Name of the relation - must be specified in model template |
| getJoinCondition | ( | ) |
| save | ( | $record | ) |
Save $record as relation of the owner.
Example: Add post to the user: $user->posts->save($post);
| Model | array | $record | Record to be saved. |