public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) { $criteria = clone $criteria; $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME); if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { ProductPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); } foreach (sfMixer::getCallables('BaseProductPeer:doCount:doCount') as $callable) { call_user_func($callable, 'BaseProductPeer', $criteria, $con); } $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; } $stmt->closeCursor(); return $count; }
public function testDoCount() { try { $c = new Criteria(); $c->add(BookPeer::ID, 12, ' BAD SQL'); BookPeer::addSelectColumns($c); BasePeer::doCount($c); } catch (PropelException $e) { $this->assertContains('[SELECT COUNT(*) FROM `book` WHERE book.ID BAD SQL:p1]', $e->getMessage(), 'SQL query is written in the exception message'); } }
public function checkForRepeatedNames($validator, $value) { $criteria = new Criteria(); $criteria->add(QubitTerm::ID, $this->resource->id, Criteria::NOT_EQUAL); $criteria->add(QubitTerm::TAXONOMY_ID, $this->resource->taxonomyId); $criteria->addJoin(QubitTerm::ID, QubitTermI18n::ID); $criteria->add(QubitTermI18n::CULTURE, $this->context->user->getCulture()); $criteria->add(QubitTermI18n::NAME, $value); if (0 < intval(BasePeer::doCount($criteria)->fetchColumn(0))) { throw new sfValidatorError($validator, $this->context->i18n->__('Name - A term with this name already exists.')); } }
public function execute($request) { if (!isset($request->limit)) { $request->limit = sfConfig::get('app_hits_per_page'); } $this->resource = $this->getRoute()->resource; $criteria = new Criteria(); $criteria->add(QubitRelation::SUBJECT_ID, $this->resource->id); $criteria->add(QubitRelation::TYPE_ID, QubitTerm::HAS_PHYSICAL_OBJECT_ID); $criteria->addJoin(QubitRelation::OBJECT_ID, QubitInformationObject::ID); $this->informationObjects = QubitInformationObject::get($criteria); $c2 = clone $criteria; $this->foundcount = BasePeer::doCount($c2)->fetchColumn(0); }
public function testDoCountDuplicateColumnName() { $con = Propel::getConnection(); $c = new Criteria(); $c->addSelectColumn(BookPeer::ID); $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID); $c->addSelectColumn(AuthorPeer::ID); $c->setLimit(3); try { $count = BasePeer::doCount($c, $con); } catch (Exception $e) { $this->fail('doCount() cannot deal with a criteria selecting duplicate column names '); } }
public function execute($request) { $this->resource = $this->getRoute()->resource; if (!isset($this->resource)) { $this->forward404(); } if (!$this->getUser()->isAuthenticated()) { QubitAcl::forwardUnauthorized(); } $criteria = new Criteria(); $criteria->setDistinct(); $criteria->add(QubitInformationObject::LFT, $this->resource->lft, Criteria::GREATER_EQUAL); $criteria->add(QubitInformationObject::RGT, $this->resource->rgt, Criteria::LESS_EQUAL); $criteria->add(QubitRelation::TYPE_ID, QubitTerm::HAS_PHYSICAL_OBJECT_ID); $criteria->addJoin(QubitRelation::OBJECT_ID, QubitInformationObject::ID); $criteria->addJoin(QubitRelation::SUBJECT_ID, QubitPhysicalObject::ID); $this->physicalObjects = QubitPhysicalObject::get($criteria); if (0 == count($this->physicalObjects)) { return sfView::ERROR; } $c2 = clone $criteria; $this->foundcount = BasePeer::doCount($c2)->fetchColumn(0); }
public function execute($request) { $this->thumbnails = array(); // Set limit (null for no limit) if (!isset($request->showFullImageflow) || 'true' != $request->showFullImageflow) { $this->limit = sfConfig::get('app_hits_per_page', 10); } // Add thumbs $criteria = new Criteria(); $criteria->addJoin(QubitInformationObject::ID, QubitDigitalObject::INFORMATION_OBJECT_ID); $criteria->add(QubitInformationObject::LFT, $this->resource->lft, Criteria::GREATER_THAN); $criteria->add(QubitInformationObject::RGT, $this->resource->rgt, Criteria::LESS_THAN); if (isset($this->limit)) { $criteria->setLimit($this->limit); } foreach (QubitDigitalObject::get($criteria) as $item) { $thumbnail = $item->getRepresentationByUsage(QubitTerm::THUMBNAIL_ID); if (!$thumbnail) { $thumbnail = QubitDigitalObject::getGenericRepresentation($item->mimeType, QubitTerm::THUMBNAIL_ID); $thumbnail->setParent($item); } $this->thumbnails[] = $thumbnail; } // Get total number of descendant digital objects $this->total = 0; if (isset($this->resource)) { $criteria = new Criteria(); $criteria->addJoin(QubitInformationObject::ID, QubitDigitalObject::INFORMATION_OBJECT_ID); $criteria->add(QubitInformationObject::LFT, $this->resource->lft, Criteria::GREATER_THAN); $criteria->add(QubitInformationObject::RGT, $this->resource->rgt, Criteria::LESS_THAN); $this->total = BasePeer::doCount($criteria)->fetchColumn(0); } if (2 > count($this->thumbnails)) { return sfView::NONE; } }
public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) { // we may modify criteria, so copy it first $criteria = clone $criteria; // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. $criteria->setPrimaryTableName(FormularioPeer::TABLE_NAME); if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { FormularioPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count $criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName if ($con === null) { $con = Propel::getConnection(FormularioPeer::DATABASE_NAME, Propel::CONNECTION_READ); } foreach (sfMixer::getCallables('BaseFormularioPeer:doCount:doCount') as $callable) { call_user_func($callable, 'BaseFormularioPeer', $criteria, $con); } $criteria = self::kriterio($criteria); // BasePeer returns a PDOStatement $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
public static function doCountJoinAllExceptTipolocacion(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { LocacionPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(LocacionPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(array(LocacionPeer::FK_PROVINCIA_ID), array(ProvinciaPeer::ID), $join_behavior); $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; } $stmt->closeCursor(); return $count; }
/** * Returns the number of rows matching criteria, joining the related AbsenceEleveLieu table * * @param Criteria $criteria * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ public static function doCountJoinAllExceptAbsenceEleveLieu(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. $criteria->setPrimaryTableName(AbsenceEleveSaisiePeer::TABLE_NAME); if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { AbsenceEleveSaisiePeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY should not affect count // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(AbsenceEleveSaisiePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(AbsenceEleveSaisiePeer::UTILISATEUR_ID, UtilisateurProfessionnelPeer::LOGIN, $join_behavior); $criteria->addJoin(AbsenceEleveSaisiePeer::ELEVE_ID, ElevePeer::ID_ELEVE, $join_behavior); $criteria->addJoin(AbsenceEleveSaisiePeer::ID_EDT_CRENEAU, EdtCreneauPeer::ID_DEFINIE_PERIODE, $join_behavior); $criteria->addJoin(AbsenceEleveSaisiePeer::ID_EDT_EMPLACEMENT_COURS, EdtEmplacementCoursPeer::ID_COURS, $join_behavior); $criteria->addJoin(AbsenceEleveSaisiePeer::ID_GROUPE, GroupePeer::ID, $join_behavior); $criteria->addJoin(AbsenceEleveSaisiePeer::ID_CLASSE, ClassePeer::ID, $join_behavior); $criteria->addJoin(AbsenceEleveSaisiePeer::ID_AID, AidDetailsPeer::ID, $join_behavior); // soft_delete behavior if (AbsenceEleveSaisieQuery::isSoftDeleteEnabled()) { $criteria->add(AbsenceEleveSaisiePeer::DELETED_AT, null, Criteria::ISNULL); } else { AbsenceEleveSaisiePeer::enableSoftDelete(); } $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
public static function doCountJoinAllExceptPeriodo(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { ExamenPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(ExamenPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(array(ExamenPeer::FK_ESCALANOTA_ID), array(EscalanotaPeer::ID), $join_behavior); $criteria->addJoin(array(ExamenPeer::FK_ALUMNO_ID), array(AlumnoPeer::ID), $join_behavior); $criteria->addJoin(array(ExamenPeer::FK_ACTIVIDAD_ID), array(ActividadPeer::ID), $join_behavior); $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; } $stmt->closeCursor(); return $count; }
public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; $criteria->setPrimaryTableName(ActividadPeer::TABLE_NAME); if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { ActividadPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(ActividadPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(array(ActividadPeer::FK_ESTABLECIMIENTO_ID), array(EstablecimientoPeer::ID), $join_behavior); $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; } $stmt->closeCursor(); return $count; }
/** * Returns the number of rows matching criteria, joining the related ReservationRelatedByReservationparentId table * * @param Criteria $c * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ public static function doCountJoinAllExceptReservationRelatedByReservationparentId(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { ReservationPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(ReservationPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(array(ReservationPeer::ROOMPROFILE_ID), array(RoomprofilePeer::ID), $join_behavior); $criteria->addJoin(array(ReservationPeer::ACTIVITY_ID), array(ActivityPeer::ID), $join_behavior); $criteria->addJoin(array(ReservationPeer::RESERVATIONREASON_ID), array(ReservationreasonPeer::ID), $join_behavior); $criteria->addJoin(array(ReservationPeer::USERGROUP_ID), array(UsergroupPeer::ID), $join_behavior); $criteria->addJoin(array(ReservationPeer::CARD_ID), array(CardPeer::ID), $join_behavior); $criteria->addJoin(array(ReservationPeer::USER_ID), array(UserPeer::ID), $join_behavior); foreach (sfMixer::getCallables('BaseReservationPeer:doCount:doCount') as $callable) { call_user_func($callable, 'BaseReservationPeer', $criteria, $con); } $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
/** * Returns the number of rows matching criteria, joining the related MemberRelatedByMasterMemberId table * * @param Criteria $c * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ public static function doCountJoinAllExceptMemberRelatedByMasterMemberId(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { MemberPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(MemberPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(array(MemberPeer::PERSON_ID), array(PersonPeer::ID), $join_behavior); $criteria->addJoin(array(MemberPeer::WING_ID), array(WingPeer::ID), $join_behavior); $criteria->addJoin(array(MemberPeer::MEMBER_CLASS_ID), array(MemberClassPeer::ID), $join_behavior); foreach (sfMixer::getCallables('BaseMemberPeer:doCount:doCount') as $callable) { call_user_func($callable, 'BaseMemberPeer', $criteria, $con); } $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
/** * Returns the number of rows matching criteria, joining the related ModifieParUtilisateur table * * @param Criteria $criteria * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ public static function doCountJoinAllExceptModifieParUtilisateur(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. $criteria->setPrimaryTableName(AbsenceEleveTraitementPeer::TABLE_NAME); if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { AbsenceEleveTraitementPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY should not affect count // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(AbsenceEleveTraitementPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(AbsenceEleveTraitementPeer::A_TYPE_ID, AbsenceEleveTypePeer::ID, $join_behavior); $criteria->addJoin(AbsenceEleveTraitementPeer::A_MOTIF_ID, AbsenceEleveMotifPeer::ID, $join_behavior); $criteria->addJoin(AbsenceEleveTraitementPeer::A_JUSTIFICATION_ID, AbsenceEleveJustificationPeer::ID, $join_behavior); // soft_delete behavior if (AbsenceEleveTraitementQuery::isSoftDeleteEnabled()) { $criteria->add(AbsenceEleveTraitementPeer::DELETED_AT, null, Criteria::ISNULL); } else { AbsenceEleveTraitementPeer::enableSoftDelete(); } $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
/** * Returns the number of rows matching criteria, joining the related PcUser table * * @param Criteria $criteria * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ public static function doCountJoinAllExceptPcUser(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. $criteria->setPrimaryTableName(PcBlogCommentPeer::TABLE_NAME); if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { PcBlogCommentPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY should not affect count // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(PcBlogCommentPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(PcBlogCommentPeer::POST_ID, PcBlogPostPeer::ID, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BasePcBlogCommentPeer', $criteria, $con); } $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
public static function doCountJoinAllExceptArticle(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { AuthorArticlePeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(AuthorArticlePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(array(AuthorArticlePeer::AUTHOR_ID), array(AuthorPeer::ID), $join_behavior); foreach (sfMixer::getCallables('BaseAuthorArticlePeer:doCount:doCount') as $callable) { call_user_func($callable, 'BaseAuthorArticlePeer', $criteria, $con); } $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; } $stmt->closeCursor(); return $count; }
/** * Returns the number of rows matching criteria, joining the related Usuario table * * @param Criteria $c * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ public static function doCountJoinAllExceptUsuario(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { HistoricoDocumentoPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(HistoricoDocumentoPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(array(HistoricoDocumentoPeer::ID_EMPRESA), array(EmpresaPeer::ID_EMPRESA), $join_behavior); $criteria->addJoin(array(HistoricoDocumentoPeer::ID_DOCUMENTO), array(DocumentoPeer::ID_DOCUMENTO), $join_behavior); foreach (sfMixer::getCallables('BaseHistoricoDocumentoPeer:doCount:doCount') as $callable) { call_user_func($callable, 'BaseHistoricoDocumentoPeer', $criteria, $con); } $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
/** * Returns the number of rows matching criteria, joining the related sfAssetFolder table * * @param Criteria $c * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ public static function doCountJoinAllExceptsfAssetFolder(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { PropertyPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(PropertyPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(array(PropertyPeer::OFFER_ID), array(OfferPeer::ID), $join_behavior); $criteria->addJoin(array(PropertyPeer::TYPE_ID), array(TypePeer::ID), $join_behavior); $criteria->addJoin(array(PropertyPeer::TYPOLOGY_ID), array(TypologyPeer::ID), $join_behavior); $criteria->addJoin(array(PropertyPeer::STATE_ID), array(StatePeer::ID), $join_behavior); $criteria->addJoin(array(PropertyPeer::KITCHEN_ID), array(KitchenPeer::ID), $join_behavior); foreach (sfMixer::getCallables('BasePropertyPeer:doCount:doCount') as $callable) { call_user_func($callable, 'BasePropertyPeer', $criteria, $con); } $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
/** * Get count of digital objects by media-type */ public static function getCount($mediaTypeId) { $criteria = new Criteria(); $criteria->add(QubitDigitalObject::PARENT_ID, null, Criteria::ISNULL); $criteria->add(QubitDigitalObject::MEDIA_TYPE_ID, $mediaTypeId); $criteria->addJoin(QubitDigitalObject::INFORMATION_OBJECT_ID, QubitInformationObject::ID); $criteria = QubitAcl::addFilterDraftsCriteria($criteria); return BasePeer::doCount($criteria)->fetchColumn(0); }
/** * Returns the number of rows matching criteria, joining the related Venta table * * @param Criteria $criteria * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ public static function doCountJoinAllExceptVenta(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. $criteria->setPrimaryTableName(FacturaPeer::TABLE_NAME); if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { FacturaPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY should not affect count // Set the correct dbName $criteria->setDbName(FacturaPeer::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(FacturaPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(FacturaPeer::IDADMISION, AdmisionPeer::IDADMISION, $join_behavior); $criteria->addJoin(FacturaPeer::IDCONSULTA, ConsultaPeer::IDCONSULTA, $join_behavior); $criteria->addJoin(FacturaPeer::IDDATOSFACTURACION, PacientefacturacionPeer::IDPACIENTEFACTURACION, $join_behavior); $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
public static function doCountJoinAllExceptProvincia(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { EstablecimientoPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(EstablecimientoPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(array(EstablecimientoPeer::FK_DISTRITOESCOLAR_ID), array(DistritoescolarPeer::ID), $join_behavior); $criteria->addJoin(array(EstablecimientoPeer::FK_ORGANIZACION_ID), array(OrganizacionPeer::ID), $join_behavior); $criteria->addJoin(array(EstablecimientoPeer::FK_NIVELTIPO_ID), array(NiveltipoPeer::ID), $join_behavior); $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; } $stmt->closeCursor(); return $count; }
/** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * * Use this method directly if you want to work with an executed statement durirectly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. * @param PropelPDO $con The connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. * @return PDOStatement The executed PDOStatement object. * @see BasePeer::doCount() */ public static function doCountStmt(Criteria $criteria, PropelPDO $con = null) { // attach default criteria PermissionPeer::attachCriteriaFilter($criteria); // set the connection to slave server $con = PermissionPeer::alternativeCon($con); // BasePeer returns a PDOStatement return BasePeer::doCount($criteria, $con); }
/** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * * Use this method directly if you want to work with an executed statement durirectly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. * @param PropelPDO $con The connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. * @return PDOStatement The executed PDOStatement object. * @see BasePeer::doCount() */ public static function doCountStmt(Criteria $criteria, PropelPDO $con = null) { // attach default criteria GenericDistributionProviderActionPeer::attachCriteriaFilter($criteria); // select the connection for the query $con = GenericDistributionProviderActionPeer::alternativeCon($con); // BasePeer returns a PDOStatement return BasePeer::doCount($criteria, $con); }
/** * Returns the number of rows matching criteria, joining the related ModuleHook table * * @param Criteria $c * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ public static function doCountJoinAllExceptModuleHook(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { ModulePeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(array(ModulePeer::ADD_ON), array(AddOnPeer::ID), $join_behavior); $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
/** * Returns the number of rows matching criteria, joining the related Coordinator table * * @param Criteria $c * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ public static function doCountJoinAllExceptCoordinator(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { MissionPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(MissionPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(array(MissionPeer::REQUEST_ID), array(MissionRequestPeer::ID), $join_behavior); $criteria->addJoin(array(MissionPeer::ITINERARY_ID), array(ItineraryPeer::ID), $join_behavior); $criteria->addJoin(array(MissionPeer::MISSION_TYPE_ID), array(MissionTypePeer::ID), $join_behavior); $criteria->addJoin(array(MissionPeer::PASSENGER_ID), array(PassengerPeer::ID), $join_behavior); $criteria->addJoin(array(MissionPeer::REQUESTER_ID), array(RequesterPeer::ID), $join_behavior); $criteria->addJoin(array(MissionPeer::AGENCY_ID), array(AgencyPeer::ID), $join_behavior); $criteria->addJoin(array(MissionPeer::OTHER_REQUESTER_ID), array(RequesterPeer::ID), $join_behavior); $criteria->addJoin(array(MissionPeer::OTHER_AGENCY_ID), array(AgencyPeer::ID), $join_behavior); $criteria->addJoin(array(MissionPeer::CAMP_ID), array(CampPeer::ID), $join_behavior); foreach (sfMixer::getCallables('BaseMissionPeer:doCount:doCount') as $callable) { call_user_func($callable, 'BaseMissionPeer', $criteria, $con); } $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
/** * Returns the number of rows matching criteria, joining the related NagiosCommandRelatedByGlobalHostEventHandler table * * @param Criteria $c * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ public static function doCountJoinAllExceptNagiosCommandRelatedByGlobalHostEventHandler(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. $criteria->setPrimaryTableName(NagiosMainConfigurationPeer::TABLE_NAME); if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { NagiosMainConfigurationPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY should not affect count // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(NagiosMainConfigurationPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }
private static function getFullTree($currentNode, $limit) { $tree = array(); // Get direct ancestors $ancestors = $currentNode->getAncestors()->orderBy('lft'); foreach ($ancestors as $ancestor) { $tree[$ancestor->id] = $ancestor; } // Get siblings (with limit) - but don't show sibling collection roots $totalSiblings = 0; $criteria = new Criteria(); $criteria->add(QubitTerm::PARENT_ID, $currentNode->parentId); if (QubitTerm::ROOT_ID == $currentNode->parentId) { $criteria->add(QubitTerm::TAXONOMY_ID, $currentNode->taxonomyId); } $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitTerm'); $criteria->addAscendingOrderByColumn('name'); if (0 < $limit) { $criteria->setLimit($limit); } foreach (QubitTerm::get($criteria) as $item) { // Keep track of position of $currentNode in array if ($item === $currentNode) { $curIndex = count($tree); } $tree[] = $item; } $totalSiblings = intval(BasePeer::doCount($criteria->setLimit(0))->fetchColumn(0)); // Add current object to $tree if it wasn't added as a sibling if (!isset($curIndex)) { if ($totalSiblings >= $limit) { // replace last sibling with current object array_splice($tree, -1, 1, array($currentNode)); } else { $tree[] = $currentNode; } $curIndex = count($tree) - 1; } if ($totalSiblings > $limit) { $tree[] = array('total' => $totalSiblings, 'limit' => $limit, 'parentId' => $currentNode->parentId); } // Get children (with limit) $totalChildren = 0; $criteria = new Criteria(); $criteria->add(QubitTerm::PARENT_ID, $currentNode->id); $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitTerm'); $criteria->addAscendingOrderByColumn('name'); if (0 < $limit) { $criteria->setLimit($limit); } if (0 < count($children = QubitTerm::get($criteria))) { foreach ($children as $item) { $childs[] = $item; } $totalChildren = intval(BasePeer::doCount($criteria->setLimit(0))->fetchColumn(0)); if ($totalChildren > $limit) { $childs[] = array('total' => $totalChildren, 'limit' => $limit, 'parentId' => $currentNode->id); } // Insert children right AFTER current info object in array if ($curIndex == count($tree) - 1) { $tree = array_merge($tree, $childs); } else { array_splice($tree, $curIndex + 1, 0, $childs); } } return $tree; }
/** * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. * * Use this method directly if you want to work with an executed statement durirectly (for example * to perform your own object hydration). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. * @param PropelPDO $con The connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. * @return PDOStatement The executed PDOStatement object. * @see BasePeer::doCount() */ public static function doCountStmt(Criteria $criteria, PropelPDO $con = null) { // attach default criteria MetadataProfilePeer::attachCriteriaFilter($criteria); // select the connection for the query $con = MetadataProfilePeer::alternativeCon($con); // BasePeer returns a PDOStatement return BasePeer::doCount($criteria, $con); }
/** * Returns the number of rows matching criteria, joining the related UserRelatedByUpdatedBy table * * @param Criteria $criteria * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return int Number of matching rows. */ public static function doCountJoinAllExceptUserRelatedByUpdatedBy(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; // We need to set the primary table name, since in the case that there are no WHERE columns // it will be impossible for the BasePeer::createSelectSql() method to determine which // tables go into the FROM clause. $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME); if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->setDistinct(); } if (!$criteria->hasSelectClause()) { DocumentPeer::addSelectColumns($criteria); } $criteria->clearOrderByColumns(); // ORDER BY should not affect count // Set the correct dbName $criteria->setDbName(DocumentPeer::DATABASE_NAME); if ($con === null) { $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria->addJoin(DocumentPeer::LANGUAGE_ID, LanguagePeer::ID, $join_behavior); $criteria->addJoin(DocumentPeer::DOCUMENT_TYPE_ID, DocumentTypePeer::ID, $join_behavior); $criteria->addJoin(DocumentPeer::DOCUMENT_CATEGORY_ID, DocumentCategoryPeer::ID, $join_behavior); $criteria->addJoin(DocumentPeer::HASH, DocumentDataPeer::HASH, $join_behavior); $stmt = BasePeer::doCount($criteria, $con); if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int) $row[0]; } else { $count = 0; // no rows returned; we infer that means 0 matches. } $stmt->closeCursor(); return $count; }