static function getByModelAndObjectQuery($model, Doctrine_Record $object) { if (!$object->exists()) { throw new Exception("Can't get " . LsString::pluralize($model) . " by new object"); } $alias = substr(strtolower($model), 0, 1); return LsDoctrineQuery::create()->from($model . ' ' . $alias)->where($alias . '.object_model = ? AND ' . $alias . '.object_id = ?', array(get_class($object), $object->id)); }