Skip to content

Instantly share code, notes, and snippets.

@sousk
Created November 16, 2009 09:32
Show Gist options
  • Save sousk/235879 to your computer and use it in GitHub Desktop.
Save sousk/235879 to your computer and use it in GitHub Desktop.
/**
* #test retrieveBy
* <code>
* #ok($t = TagPeer::retrieveBy('slug', 'culture'));
* #is($t->getSlug(), 'culture');
* #is($t = TagPeer::retrieveBy('slug', 'culturecult23') ,NULL);
* </code>
*/
public static function getCriteria($c=null)
{
if (! $c) {
$c = new Criteria;
$c->add(self::DELETED_AT, null);
}
return $c;
}
public static function retrieveBy($col, $value)
{
static $ref;
if (! $ref) {
$ref = new ReflectionClass(__CLASS__);
}
$c = self::getCriteria();
$c->add($ref->getConstant(strtoupper($col)), $value);
return self::doSelectOne($c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment