$_model
$_model :
Sort of Active Record Class
$_a :
Store the attributes of the model.
To minimize pollution of the property space, all the attributes are stored in this array.
Description of the keys: 'multitenant: Determines possibility of define the model in each tenant separately 'mapped': Determines that the model is a mapped model of another model. A mapped model have not a separate table. 'table': The table in which the model is stored. 'model': The name of the model. 'cols': The definition of the columns. 'idx': The definition of the indexes. 'views': The definition of the views. 'verbose': The verbose name of the model.
getData() : array
Get the raw data of the object.
For the many to many relations, the value is an array of ids.
Associative array of the data.
None found |
setAssoc( $model)
Set the association of a model to another in many to many.
$model |
None found |
delAssoc( $model)
Set the association of a model to another in many to many.
$model |
None found |
batchAssoc( $model_name, $ids) : boolean
Bulk association of models to the current one.
$model_name | ||
$ids |
Success
None found |
None found |
None found |
getSqlTable()
Get the table of the model.
Avoid doing the concatenation of the prefix and the table manually.
None found |
None found |
None found |
None found |
get( $id) : mixed
Get a given item.
$id |
Item or false if not found.
None found |
getOne( $p = array()) : \Pluf_Model|null
Get one item.
The parameters are the same as the ones of the getList method, but, the return value is either:
Usage:
$m = Pluf::factory(My_Model::class)->getOne(array('filter' => 'id=1'));
$m = Pluf::factory(My_Model::class)->getOne('id=1');
$p |
find model
None found |
getList( $p = array()) : \ArrayObject
یک فهرست از موجودیتها را تعیین میکند
The filter should be used only for simple filtering. If you want a complex query, you should create a new view. Both filter and order accept an array or a string in case of multiple parameters: Filter: array('col1=toto', 'col2=titi') will be used in a AND query or simply 'col1=toto' Order: array('col1 ASC', 'col2 DESC') or 'col1 ASC'
This is modelled on the DB_Table pear module interface.
$p |
of items or through an exception if database failure
None found |
getCount( $p = array()) : integer
Get the number of items.
$p |
The number of items
None found |
getRelated( $model, $method = null, $p = array()) : array
Get a list of related items.
See the getList() method for usage of the view and filters.
$model | ||
$method | ||
$p |
Array of items
None found |
None found |
update( $where = '') : boolean
Update the model into the database.
If no where clause is provided, the index definition is used to find the sequence. These are used to limit the update to the current model.
$where |
Success
None found |
create( $raw = false) : boolean
Create the model into the database.
If raw insert is requested, the preSave/postSave methods are not called and the current id of the object is directly used. This is particularily used when doing backup/restore of data.
$raw |
Success
None found |
getDeleteSideEffect() : array
Get models affected by delete.
Models deleted if deleting current model.
None found |
delete()
Delete the current model from the database.
If another model link to the current model through a foreign key, the DB is responsible to mange relations.
None found |
None found |
__toString() : string
Represents the model in auto generated lists.
You need to overwrite this method to have a nice display of your objects in the select boxes, logs.
reperesentation of the current object
None found |
restore()
Hook run just after loading a model from the database.
Just overwrite it into your model to perform custom actions.
None found |
preSave( $create = false)
\brief پیش ذخیره را انجام میدهد
در صورتی که نیاز به انجام پردازشهایی قبل از ذخیره شدن مدل دادهای دارید، این فراخوانی را بازنویسی کنید.
$create | boolean ساخت یا به روز رسانی را تعیین میکند |
None found |
None found |
preDelete()
Hook run just before deleting a model from the database.
Just overwrite it into your model to perform custom actions.
None found |
setFromFormData( $cleaned_values)
مقادیر مدل را بر اساس یک فرم تعیین میکند
این مقادیر به صورت یک آرایه به عنوان ورودی دریافت شده و بر اساس آن دادههای مورد نیاز مدل تعیین میشود.
$cleaned_values |
None found |
None found |
_toDb( $val, $col) : string
Prepare the value to be put in the DB.
$val | ||
$col |
SQL ready string.
None found |
_fromDb( $val, $col) : mixed
Get the value from the DB.
Create DB field and returns. The field type is used as the output value type.
$val | ||
$col |
Value.
None found |
displayVal( $col) : mixed
Display value.
When you have a list of choices for a field and you want to get the display value of the current stored value.
$col |
Display value, if not available default to the value.
None found |
isAnonymous() : boolean
بررسی میکند که آیا مدل دادهای وجود دارد یا نه
در صورتی که مدل دادهای ذخیره نشده باشد به عنوان داده بی نام و نشان در نظر گرفته میشود. در مورد کاربران این تابع کاربرد فراوان دارد.
True if the user is anonymous.
None found |
getClass() : string
مدل دادهای را تعیین میکند
هر مدل دادهای یک نام دارد.
این فراخوانی نام مدل دادهای را تعیین میکند که معادل با نام کلاس است.
None found |
None found |
None found |
None found |
None found |
isBelongTo(\Shop_Order $order) : boolean
Check if this item is blong to given Shop_Order
\Shop_Order | $order |
None found |
_setupAutomaticListMethods(string $type)
متدهای اتوماتیک را برای مدل ورودی ایجاد میکند.
Adds the get_xx_list method when the methods of the model contains custom names.
string | $type | Relation type: 'foreignkey' or 'manytomany'. |
None found |
_setupMultitenantFields()
Add tenant required fields
Adds extra fields if multi-tenant is enabled
None found |
None found |