Closed thehawk970 closed 8 months ago
Take a look to http://pastebin.com/PwqBYUaK i think its usefull to understand what i wrote :D
Désolé de venir aussi tardivement sur le sujet, mais je pense qu'il faut éviter le plus possible le fetchAll() systématique. Le chargement des données dans un tableau dès le lancement de la requête n'est pas une bonne idée, et on devrait plutôt avoir une activerecord sur un statement... @metalaka avait fait quelque chose d'intéressant à ce sujet
I think its could be cool for sohoa :)
This mix for ActiveRecord Pattern and classic mapping model
You can use both
$model['hello'] = 'world'
and$model->insert('foo', 'bar');
Mapping layer
You use 4 methods
map()
,unmap($key, $value)
,_update(Array $array)
andmode()
map()
This function must return an array which use in the model
Pro-tip
The parameter pass on the construct will be transmit to map function
$model = new \Application\Model\Foobar($hello, $bar);
The function map will be execute with $this->map($hello, $bar);
unmap($key, $value)
This function will call on each value change if you change :
Will call 2 times the function
unmap('foo' , 'bar')
andunmap('bar', 'qux')
Be careful for spamming !_update
This function will call manually when you call
$model->update()
function with an only one argument which contains the changed value of your modelstatic mode ($save, $update)
This method configue the class $save has two values
SAVE_IMMEDIATE
andSAVE_MANU
$update has too two valuesUPDATE_ALL_VALUE
andUPDATE_CHANGE_VALUE
SAVE_IMMEDIATE
: we call automatically the method unmap on update valueSAVE_MANU
: do nothing on update value, and need to call manually the->update()
methodUPDATE_ALL_VALUE
: we send all value for _update, not operative in immediate option !UPDATE_CHANGE_VALUE
: send only the changed value of your modelActiveRecord Pattern
Nothing on the data manipulation only some feature for send data to database, like
->sql($requete)
which accept and\Hoa\Model\Query
object or an string, an return the instance you can combine withall()
,first()
,last()
,count()
anditem($id)
i think this is logic :pI had a little system for logging what happens and the number of result, you can get the result with
::getSqlLog()
i think its usefull when you have tons of requetes :DHave fun ps : I do some test :'D, and i code that for mojo but i think its cool for sohoa ps2 : sorry for my english and good for translate :'D