本文整理汇总了PHP中QueryObject::setBaseEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryObject::setBaseEntity方法的具体用法?PHP QueryObject::setBaseEntity怎么用?PHP QueryObject::setBaseEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryObject
的用法示例。
在下文中一共展示了QueryObject::setBaseEntity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBy
public function getBy(QueryObject $query)
{
$class = $this->entity_class;
$query->setBaseEntity(new $class());
$filter = (string) $query;
$do = $class::get()->where($filter);
$joins = $query->getAlias();
foreach ($joins as $table => $clause) {
$do = $do->innerJoin($table, $clause);
}
if (count($query->getOrder())) {
$do = $do->sort($query->getOrder());
}
if (is_null($do)) {
return false;
}
$entity = $do->first();
$this->markEntity($entity);
return $entity;
}
示例2: getBy
public function getBy(QueryObject $query)
{
$class = $this->entity_class;
$query->setBaseEntity(new $class());
$filter = (string) $query;
$do = $class::get()->where($filter);
foreach ($query->getAlias(QueryAlias::INNER) as $spec) {
$do = $do->innerJoin($spec->getTable(), $spec->getCondition(), $spec->getAlias());
}
foreach ($query->getAlias(QueryAlias::LEFT) as $spec) {
$do = $do->leftJoin($spec->getTable(), $spec->getCondition(), $spec->getAlias());
}
if (count($query->getOrder())) {
$do = $do->sort($query->getOrder());
}
if (is_null($do)) {
return false;
}
$entity = $do->first();
$this->markEntity($entity);
return $entity;
}
示例3: getBy
public function getBy(QueryObject $query)
{
$class = $this->entity_class;
$query->setBaseEntity(new $class());
$filter = (string) $query;
$do = $class::get()->where($filter);
$joins = $query->getAlias();
foreach ($joins as $table => $clause) {
$do = $do->innerJoin($table, $clause);
}
if (count($query->getOrder())) {
$do = $do->sort($query->getOrder());
}
if (is_null($do)) {
return false;
}
$entity = $do->first();
if (!is_null($entity) && $entity instanceof IEntity) {
UnitOfWork::getInstance()->setToCache($entity);
UnitOfWork::getInstance()->scheduleForUpdate($entity);
}
return $entity;
}