Pluf Framework

Pluf Framework Commit Details


Date:2009-05-22 06:17:05 (15 years 7 months ago)
Author:Loic d'Anterroches
Branch:develop, master
Commit:f1f23bc18093471e76cbc50e7e7c854138c3cf24
Parents: f283c3a2d07073d5d704d97ac11ed05433a12a1a
Message:Added a shortcuts to get one object or throw a 404 exception.

Changes:

File differences

src/Pluf/Shortcuts.php
4444
4545
4646
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
4772
4873
4974
}
/**
* Get an object by SQL or raise a 404 error.
*
* Usage:
* <pre>
* $obj = Pluf_Shortcuts_GetOneOr404('MyApp_Model',
* 'path=%s AND status=%s',
* array('welcome', 1));
* </pre>
*
* @param string Model
* @param string Base SQL request
* @param string Parameters for the base SQL
* @return Object The found object
*/
function Pluf_Shortcuts_GetOneOr404($object, $bsql, $psql)
{
$sql = new Pluf_SQL($bsql, $psql);
$item = Pluf::factory($object)->getOne(array('filter' => $sql->gen()));
if ($item != null) {
return $item;
}
throw new Pluf_HTTP_Error404();
}
/**
* Render a template file and an array as a reponse.
*
* If a none null request object is given, the context used will

Archive Download the corresponding diff file

Branches

Tags

Number of commits:
Page rendered in 0.05256s using 13 queries.