Pluf Framework

Pluf Framework Commit Details


Date:2009-05-15 04:56:50 (15 years 7 months ago)
Author:Loic d'Anterroches
Branch:develop, master
Commit:7aa17fcfc9204c4d139f3b72c464f1a58261ac23
Parents: 95a9768590da0f57ff54214e8dcdd54da2caa081
Message:Fixed issue 184, added a getOne method.

Changes:

File differences

src/Pluf/Model.php
406406
407407
408408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
409439
410440
411441
}
/**
* Get one item.
*
* The parameters are the same as the ones of the getList method,
* but, the return value is either:
*
* - The object
* - null if no match
* - Exception if the match results in more than one item.
*
* Usage:
*
* <pre>
* $m = Pluf::factory('My_Model')->getOne(array('filter' => 'id=1'));
* </pre>
*
* @see self::getList
*/
public function getOne($p=array())
{
$items = $this->getList($p);
if ($items->count() == 1) {
return $items[0];
}
if ($items->count() == 0) {
return null;
}
throw new Exception(__('Error: More than one matching item found.'));
}
/**
* Get a list of items.
*
* The filter should be used only for simple filtering. If you want

Archive Download the corresponding diff file

Branches

Tags

Number of commits:
Page rendered in 0.05468s using 14 queries.