本文整理汇总了PHP中Criteria::addHaving方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::addHaving方法的具体用法?PHP Criteria::addHaving怎么用?PHP Criteria::addHaving使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Criteria
的用法示例。
在下文中一共展示了Criteria::addHaving方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preDelete
public function preDelete(PropelPDO $con = null)
{
/*
* delete lvs that are not shared....numVgs=1 only
*
*/
$criteria = new Criteria();
$criteria->add(EtvaLogicalvolumePeer::CLUSTER_ID, $this->getClusterId());
$criteria->addGroupByColumn(EtvaNodeLogicalvolumePeer::LOGICALVOLUME_ID);
$criteria->addAsColumn('numLvs', 'COUNT(' . EtvaNodeLogicalvolumePeer::LOGICALVOLUME_ID . ')');
$criteria->addHaving($criteria->getNewCriterion(EtvaNodeLogicalvolumePeer::LOGICALVOLUME_ID, 'numLvs=1', Criteria::CUSTOM));
$records = EtvaNodeLogicalvolumePeer::doSelectJoinEtvaLogicalvolume($criteria);
foreach ($records as $record) {
$etva_lv = $record->getEtvaLogicalvolume();
if ($record->getNodeId() == $this->getId()) {
$etva_lv->delete();
}
}
/*
* delete vgs that are not shared....numVgs=1 only
*
*/
$criteria = new Criteria();
$criteria->add(EtvaVolumegroupPeer::CLUSTER_ID, $this->getClusterId());
$criteria->addGroupByColumn(EtvaNodeVolumegroupPeer::VOLUMEGROUP_ID);
$criteria->addAsColumn('numVgs', 'COUNT(' . EtvaNodeVolumegroupPeer::VOLUMEGROUP_ID . ')');
$criteria->addHaving($criteria->getNewCriterion(EtvaNodeVolumegroupPeer::VOLUMEGROUP_ID, 'numVgs=1', Criteria::CUSTOM));
$records = EtvaNodeVolumegroupPeer::doSelectJoinEtvaVolumegroup($criteria);
foreach ($records as $record) {
$etva_vg = $record->getEtvaVolumegroup();
if ($record->getNodeId() == $this->getId()) {
$etva_vg->delete();
}
}
/*
* delete pvs that are not shared....numVgs=1 only
*
*/
$criteria = new Criteria();
$criteria->add(EtvaPhysicalvolumePeer::CLUSTER_ID, $this->getClusterId());
$criteria->addGroupByColumn(EtvaNodePhysicalvolumePeer::PHYSICALVOLUME_ID);
$criteria->addAsColumn('numPvs', 'COUNT(' . EtvaNodePhysicalvolumePeer::PHYSICALVOLUME_ID . ')');
$criteria->addHaving($criteria->getNewCriterion(EtvaNodePhysicalvolumePeer::PHYSICALVOLUME_ID, 'numPvs=1', Criteria::CUSTOM));
$records = EtvaNodePhysicalvolumePeer::doSelectJoinEtvaPhysicalvolume($criteria);
foreach ($records as $record) {
$etva_pv = $record->getEtvaPhysicalvolume();
if ($record->getNodeId() == $this->getId()) {
$etva_pv->delete();
}
}
// delete rra node dir and cpu load rrd
$this->deleteRRAFiles();
return true;
}
示例2: testMergeWithHavingConditions
public function testMergeWithHavingConditions()
{
$c1 = new Criteria();
$cton = $c1->getNewCriterion(BookPeer::TITLE, 'foo', Criteria::EQUAL);
$c1->addHaving($cton);
$c2 = new Criteria();
$c1->mergeWith($c2);
$sql = 'SELECT FROM HAVING book.TITLE=:p1';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() does not remove an existing having condition');
$c1 = new Criteria();
$c2 = new Criteria();
$cton = $c2->getNewCriterion(BookPeer::TITLE, 'foo', Criteria::EQUAL);
$c2->addHaving($cton);
$c1->mergeWith($c2);
$sql = 'SELECT FROM HAVING book.TITLE=:p1';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges having condition to an empty having');
$c1 = new Criteria();
$cton = $c1->getNewCriterion(BookPeer::TITLE, 'foo', Criteria::EQUAL);
$c1->addHaving($cton);
$c2 = new Criteria();
$cton = $c2->getNewCriterion(BookPeer::TITLE, 'bar', Criteria::EQUAL);
$c2->addHaving($cton);
$c1->mergeWith($c2);
$sql = 'SELECT FROM HAVING (book.TITLE=:p1 AND book.TITLE=:p2)';
$this->assertCriteriaTranslation($c1, $sql, 'mergeWith() combines having with AND');
}
示例3: testAliasInCriterion
/**
* Tests including aliases in criterion objects.
* @link http://propel.phpdb.org/trac/ticket/636
*/
public function testAliasInCriterion()
{
$c = new Criteria();
$c->addAsColumn("column_alias", "tbl.COL1");
$crit = $c->getNewCriterion("column_alias", "FOO");
$this->assertNull($crit->getTable());
$this->assertEquals("column_alias", $crit->getColumn());
$c->addHaving($crit);
// produces invalid SQL referring to '.olumn_alias'
}
示例4: testHavingRaw
public function testHavingRaw()
{
$c = new Criteria();
$c->addSelectColumn(BookPeer::TITLE);
$c->addAsColumn("isb_n", BookPeer::ISBN);
$c->addHaving('isb_n = ?', '1234567890123', PDO::PARAM_STR);
$expected = 'SELECT book.TITLE, book.ISBN AS isb_n FROM book HAVING isb_n = :p1';
$params = array();
$result = BasePeer::createSelectSql($c, $params);
$this->assertEquals($expected, $result);
BasePEer::doSelect($c, $this->con);
$expected = 'SELECT book.TITLE, book.ISBN AS isb_n FROM book HAVING isb_n = \'1234567890123\'';
$this->assertEquals($expected, $this->con->getLastExecutedQuery());
}
示例5: unsuspendRootJob
private static function unsuspendRootJob($jobIds)
{
if (empty($jobIds)) {
return array();
}
// Get possible root job ids
// select root_job_id from batch_job_lock where id in (unsuspended jobs)
$c = new Criteria();
$c->addSelectColumn(BatchJobLockPeer::ROOT_JOB_ID);
$c->setDistinct();
$c->add(BatchJobLockPeer::ID, $jobIds, Criteria::IN);
$stmt = BatchJobLockPeer::doSelectStmt($c);
$rootIds = $stmt->fetchAll(PDO::FETCH_COLUMN);
// Select only root ids that has no other suspended descendats
$c = new Criteria();
$c->addSelectColumn(BatchJobLockSuspendPeer::ROOT_JOB_ID);
$c->add(BatchJobLockSuspendPeer::ROOT_JOB_ID, $rootIds, Criteria::IN);
$c->add(BatchJobLockSuspendPeer::ID, '(batch_job_lock_suspend.ID != batch_job_lock_suspend.ROOT_JOB_ID)', Criteria::CUSTOM);
$c->addGroupByColumn(BatchJobLockSuspendPeer::ROOT_JOB_ID);
$c->addHaving($c->getNewCriterion(BatchJobLockSuspendPeer::ROOT_JOB_ID, 'COUNT(batch_job_lock_suspend.ID)>0', Criteria::CUSTOM));
$stmt = BatchJobLockSuspendPeer::doSelectStmt($c);
$usedRootIds = $stmt->fetchAll(PDO::FETCH_COLUMN);
$unsuspendedRootJobs = array_diff($rootIds, $usedRootIds);
self::moveFromSuspendedJobsTable($unsuspendedRootJobs);
return $unsuspendedRootJobs;
}
示例6: getTaggings
/**
* Returns the taggings associated to one tag or a set of tags.
*
* The second optionnal parameter permits to restrict the results with
* different criterias
*
* @param mixed $tags Array of tag strings or string
* @param array $options Array of options parameters
* @return array
*/
public static function getTaggings($tags = array(), $options = array())
{
$tags = sfPropelActAsTaggableToolkit::explodeTagString($tags);
if (is_string($tags)) {
$tags = array($tags);
}
$c = new Criteria();
$c->addJoin(TagPeer::ID, TaggingPeer::TAG_ID);
if (count($tags) > 0) {
$c->add(TagPeer::NAME, $tags, Criteria::IN);
$having = $c->getNewCriterion('COUNT(' . TaggingPeer::TAGGABLE_MODEL . ') ', count($tags), Criteria::GREATER_EQUAL);
$c->addHaving($having);
}
$c->addGroupByColumn(TaggingPeer::TAGGABLE_ID);
$c->clearSelectColumns();
$c->addSelectColumn(TaggingPeer::TAGGABLE_MODEL);
$c->addSelectColumn(TaggingPeer::TAGGABLE_ID);
// Taggable model class option
if (isset($options['model'])) {
if (!class_exists($options['model']) || !is_callable(array(new $options['model'](), 'getPeer'))) {
throw new PropelException(sprintf('The class "%s" does not exist, or it is not a model class.', $options['model']));
}
$c->add(TaggingPeer::TAGGABLE_MODEL, $options['model']);
} else {
$c->addGroupByColumn(TaggingPeer::TAGGABLE_MODEL);
}
if (isset($options['triple'])) {
$c->add(TagPeer::IS_TRIPLE, $options['triple']);
}
if (isset($options['namespace'])) {
$c->add(TagPeer::TRIPLE_NAMESPACE, $options['namespace']);
}
if (isset($options['key'])) {
$c->add(TagPeer::TRIPLE_KEY, $options['key']);
}
if (isset($options['value'])) {
$c->add(TagPeer::TRIPLE_VALUE, $options['value']);
}
$param = array();
$sql = BasePeer::createSelectSql($c, $param);
$con = Propel::getConnection();
if (Propel::VERSION < '1.3') {
$stmt = $con->prepareStatement($sql);
$position = 1;
foreach ($tags as $tag) {
$stmt->setString($position, $tag);
$position++;
}
if (isset($options['model'])) {
$stmt->setString($position, $options['model']);
$position++;
}
if (isset($options['triple'])) {
$stmt->setBoolean($position, $options['triple']);
$position++;
}
if (isset($options['namespace'])) {
$stmt->setString($position, $options['namespace']);
$position++;
}
if (isset($options['key'])) {
$stmt->setString($position, $options['key']);
$position++;
}
if (isset($options['value'])) {
$stmt->setString($position, $options['value']);
$position++;
}
} else {
$stmt = $con->prepare($sql);
$position = 1;
foreach ($tags as $tag) {
$stmt->bindValue(':p' . $position, $tag, PDO::PARAM_STR);
$position++;
}
if (isset($options['model'])) {
$stmt->bindValue(':p' . $position, $options['model'], PDO::PARAM_STR);
$position++;
}
if (isset($options['triple'])) {
$stmt->bindValue(':p' . $position, $options['triple']);
$position++;
}
if (isset($options['namespace'])) {
$stmt->bindValue(':p' . $position, $options['namespace'], PDO::PARAM_STR);
$position++;
}
if (isset($options['key'])) {
$stmt->bindValue(':p' . $position, $options['key'], PDO::PARAM_STR);
$position++;
//.........这里部分代码省略.........
示例7: testHavingRaw
public function testHavingRaw()
{
$db = Propel::getDB();
$c = new Criteria();
$c->addSelectColumn(BookPeer::TITLE);
$c->addAsColumn("isb_n", BookPeer::ISBN);
$c->addHaving('isb_n = ?', '1234567890123', PDO::PARAM_STR);
$expected = 'SELECT book.title, book.isbn AS ' . $db->quoteIdentifier('isb_n') . ' FROM book HAVING isb_n = :p1';
$params = array();
$result = BasePeer::createSelectSql($c, $params);
$this->assertEquals($expected, $result);
}
示例8: addDisciplinarySanctionCountColumnCriteria
public function addDisciplinarySanctionCountColumnCriteria(Criteria $criteria, $field, $values)
{
if ($values) {
$criteria->addJoin(StudentPeer::ID, StudentDisciplinarySanctionPeer::STUDENT_ID, Criteria::INNER_JOIN);
$criteria->add(StudentDisciplinarySanctionPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId());
$criteria->addGroupByColumn(StudentDisciplinarySanctionPeer::STUDENT_ID);
$criterion = $criteria->getNewCriterion(StudentDisciplinarySanctionPeer::STUDENT_ID, 'count(' . StudentDisciplinarySanctionPeer::STUDENT_ID . ') >=' . $values, Criteria::CUSTOM);
$criteria->addHaving($criterion);
}
}
示例9: getByFilterCamp
public static function getByFilterCamp($max = 10, $page = 1, $sort_by, $availability, $first_date, $last_date, $not_available, $no_weekday, $no_weekend, $as_ma, $orgin, $dest, $airport_id, $date_range1, $date_range2, $filled, $open, $pilot, $mission_assistant, $ifr_backup, $wing, $ident, $city, $state, $zip, $day_1 = '', $day_2 = '', $day_3 = '', $day_4 = '', $day_5 = '', $day_6 = '', $day_7 = '', $all_type, $max_pass, $max_wei, $max_dist, $max_eff)
{
$c = new Criteria();
$c->addAscendingOrderByColumn(self::MISSION_ID);
$c->addJoin(self::MISSION_ID, MissionPeer::ID, Criteria::LEFT_JOIN);
$c->add(MissionPeer::CAMP_ID, null, Criteria::ISNOTNULL);
$c->add(self::TRANSPORTATION, 'air_mission', Criteria::LIKE);
$c->addGroupByColumn(MissionPeer::CAMP_ID);
$c->addJoin(MissionPeer::MISSION_TYPE_ID, MissionTypePeer::ID, Criteria::LEFT_JOIN);
$c->addJoin(self::ID, PilotRequestPeer::LEG_ID, Criteria::LEFT_JOIN);
//wing
$c->addJoin(MissionPeer::PASSENGER_ID, PassengerPeer::ID, Criteria::LEFT_JOIN);
$c->addJoin(PassengerPeer::PERSON_ID, PersonPeer::ID, Criteria::LEFT_JOIN);
$c->addJoin(PersonPeer::ID, MemberPeer::PERSON_ID, Criteria::LEFT_JOIN);
$c->addJoin(MemberPeer::WING_ID, WingPeer::ID, Criteria::LEFT_JOIN);
$c->addJoin(MemberPeer::ID, AvailabilityPeer::MEMBER_ID, Criteria::LEFT_JOIN);
if ($airport_id != null) {
$criterion = $c->getNewCriterion(self::FROM_AIRPORT_ID, $airport_id, Criteria::LIKE);
$criterion->addOR($c->getNewCriterion(self::TO_AIRPORT_ID, $airport_id, Criteria::LIKE));
$c->add($criterion);
}
if ($sort_by == '0') {
$c->addDescendingOrderByColumn(MissionPeer::MISSION_DATE);
} else {
$c->addAscendingOrderByColumn(MissionPeer::MISSION_DATE);
}
if ($not_available == 1) {
return 'You have checked "Not Available" in Availablity form!';
} else {
if ($availability == '') {
if ($first_date != null && $last_date != null) {
$criterion = $c->getNewCriterion(MissionPeer::MISSION_DATE, date('Y-m-d', strtotime($first_date)), Criteria::GREATER_EQUAL);
$criterion->addAnd($c->getNewCriterion(MissionPeer::MISSION_DATE, date('Y-m-d', strtotime($last_date)), Criteria::LESS_EQUAL));
$c->add($criterion);
}
} elseif ($availability == 'on') {
if ($date_range1 != null && $date_range2 != null) {
$criterion = $c->getNewCriterion(MissionPeer::MISSION_DATE, date('Y-m-d', strtotime($date_range1)), Criteria::GREATER_EQUAL);
$criterion->addAnd($c->getNewCriterion(MissionPeer::MISSION_DATE, date('Y-m-d', strtotime($date_range2)), Criteria::LESS_EQUAL));
$c->add($criterion);
}
#max filters
if ($max_dist) {
$c->add(self::FROM_AIRPORT_ID, 'Round(ACos(Sin(Radians(c1.latitude)) * Sin(Radians(c2.latitude)) + Cos(Radians(c1.latitude)) * Cos(Radians(c2.latitude)) * Cos(Radians(c1.longitude)-Radians(c2.longitude))) * ((180*60)/3.1415),0) < ' . (int) $max_dist, Criteria::CUSTOM);
}
$c->addGroupByColumn(CompanionPeer::PASSENGER_ID);
if ($max_pass) {
$c->addHaving($c->getNewCriterion(CompanionPeer::PASSENGER_ID, 'COUNT(' . CompanionPeer::PASSENGER_ID . ') > ' . $max_pass, Criteria::CUSTOM));
}
$c->addGroupByColumn(CompanionPeer::WEIGHT);
if ($max_wei) {
$c->addHaving($c->getNewCriterion(CompanionPeer::WEIGHT, 'SUM(' . CompanionPeer::WEIGHT . ') > ' . $max_wei, Criteria::CUSTOM));
}
$c->addJoin(MissionPeer::PASSENGER_ID, CompanionPeer::PASSENGER_ID, Criteria::LEFT_JOIN);
#max efficiency
if ($orgin == 'on' && $airport_id != null) {
$c->add(self::FROM_AIRPORT_ID, $airport_id, Criteria::LIKE);
}
if ($dest == 'on' && $airport_id != null) {
$c->add(self::TO_AIRPORT_ID, $airport_id, Criteria::LIKE);
}
if ($all_type == '') {
if ($filled == 'on') {
$c->add(MissionTypePeer::NAME, 'filled', Criteria::LIKE);
}
if ($open == 'on') {
$c->add(MissionTypePeer::NAME, 'open', Criteria::LIKE);
}
}
if ($pilot == 'on') {
$c->add(self::COPILOT_WANTED, '1', Criteria::LIKE);
}
if ($mission_assistant == 'on') {
$c->add(PilotRequestPeer::MISSION_ASSISTANT_WANTED, '1', Criteria::LIKE);
}
if ($ifr_backup == 'on') {
$c->add(PilotRequestPeer::IFR_BACKUP_WANTED, '1', Criteria::LIKE);
}
if ($as_ma) {
$c->add(PilotRequestPeer::MISSION_ASSISTANT_WANTED, '1', Criteria::LIKE);
}
if (!$no_weekday) {
//DAYS
if ($day_1) {
$c->addOr(MissionPeer::MISSION_DATE, 'date_format(' . MissionPeer::MISSION_DATE . ', "%W")="' . date('l', strtotime($day_1)) . '"', Criteria::CUSTOM);
}
if ($day_2) {
$c->addOr(MissionPeer::MISSION_DATE, 'date_format(' . MissionPeer::MISSION_DATE . ', "%W")="' . date('l', strtotime($day_2)) . '"', Criteria::CUSTOM);
}
if ($day_3) {
$c->addOr(MissionPeer::MISSION_DATE, 'date_format(' . MissionPeer::MISSION_DATE . ', "%W")="' . date('l', strtotime($day_3)) . '"', Criteria::CUSTOM);
}
if ($day_4) {
$c->addOr(MissionPeer::MISSION_DATE, 'date_format(' . MissionPeer::MISSION_DATE . ', "%W")="' . date('l', strtotime($day_4)) . '"', Criteria::CUSTOM);
}
if ($day_5) {
$c->addOr(MissionPeer::MISSION_DATE, 'date_format(' . MissionPeer::MISSION_DATE . ', "%W")="' . date('l', strtotime($day_5)) . '"', Criteria::CUSTOM);
}
}
if (!$no_weekend) {
//.........这里部分代码省略.........