本文整理匯總了PHP中Criteria::expr方法的典型用法代碼示例。如果您正苦於以下問題:PHP Criteria::expr方法的具體用法?PHP Criteria::expr怎麽用?PHP Criteria::expr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Criteria
的用法示例。
在下文中一共展示了Criteria::expr方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getLatestActivities
public function getLatestActivities($type = Activity::ACTIVITY_TYPE_COMMIT)
{
if (!in_array($type, array(Activity::ACTIVITY_TYPE_COMMIT, Activity::ACTIVITY_TYPE_RECOMMEND))) {
throw new \InvalidArgumentException();
}
$criteria = Criteria::create()->where(Criteria::expr()->eq('type', $type))->orderBy(array("createdAt" => "DESC"))->setFirstResult(0)->setMaxResults(30);
return $this->activities->matching($criteria);
}
示例2: saveEmployment
public function saveEmployment($studentobject)
{
if (!$studentobject->getPkEmploymentid()) {
$student = new \Application\Entity\Employment();
} else {
$criteria = Criteria::create()->where(Criteria::expr()->eq("pkEmploymentid", $studentobject->getPkEmploymentid()));
$student = $this->getEntity("\\Application\\Entity\\Employment", $criteria);
}
//Set user object values to be saved
$student->setFkStudentid($studentobject->getFkStudentid());
$student->setDesignation($studentobject->getDesignation());
$student->setOrganization($studentobject->getOrganization());
$student->setEndYear($studentobject->getEndYear());
$student->setStartYear($studentobject->getStartYear());
$student->setIsCurrent($studentobject->getIsCurrent());
try {
//Commit values set to the object
if (!$studentobject->getPkEmploymentid()) {
$this->em->persist($student);
}
//Save values if just updating record
$this->em->flush($student);
return $student;
} catch (Doctrine\ORM\ORMException $e) {
throw $e->getMessage();
}
}
示例3: allocate
public function allocate($object)
{
if (!$object->getPkStaffid()) {
$staff = new \Application\Entity\Staff();
} else {
$criteria = Criteria::create()->where(Criteria::expr()->eq("pkStaffid", $object->getPkStaffid()));
$staff = $this->getEntity("\\Application\\Entity\\Staff", $criteria);
}
//Set user object values to be saved
$staff->setFkUserid($object->getFkUserid());
$staff->setFkDeptid($object->getFkDeptid());
$staff->setMode($object->getMode());
try {
//Commit values set to the object
if (!$object->getPkStaffid()) {
$this->em->persist($staff);
}
//Save values if just updating record
$this->em->flush($staff);
return $staff;
} catch (Exception $e) {
throw $e->getMessages();
}
}
示例4: get_current_gradebook_category_id
/**
* Get current gradebook category id
* @return int Category id
*/
private function get_current_gradebook_category_id()
{
$curr_course_id = api_get_course_int_id();
$curr_session_id = api_get_session_id();
$em = Database::getManager();
$qb = $em->createQueryBuilder();
$qb->select('gc')->from('ChamiloCoreBundle:GradebookCategory')->where(Criteria::expr()->eq('course', $curr_course_id));
if (empty($curr_session_id)) {
$qb->andWhere($qb->expr()->isNull('sessionId'));
} else {
$qb->andWhere($qb->expr()->eq('sessionId', $curr_session_id));
}
$rs = $qb->getQuery()->getResult();
$category_id = 0;
if (count($rs) > 0) {
$row = current($rs);
$category_id = $row->getId();
}
return $category_id;
}