本文整理汇总了PHP中Criteria::getNewCriterion方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::getNewCriterion方法的具体用法?PHP Criteria::getNewCriterion怎么用?PHP Criteria::getNewCriterion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Criteria
的用法示例。
在下文中一共展示了Criteria::getNewCriterion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retrieveByPartner
/**
* fetch the best conversion profile for the partner - depending on the data in the DB only (no hint from the user)
*/
public static function retrieveByPartner($partner_id)
{
$c = new Criteria();
$c->addDescendingOrderByColumn(self::UPDATED_AT);
// make sure the first profile is the most updated
// $c->addAnd ( self::PROFILE_TYPE, $profile_type);
if ($partner_id) {
$crit = $c->getNewCriterion(self::PARTNER_ID, ConversionProfile::GLOBAL_PARTNER_PROFILE, Criteria::EQUAL);
$crit->addOr($c->getNewCriterion(self::PARTNER_ID, $partner_id, Criteria::EQUAL));
$c->add($crit);
} else {
$c->add(self::PARTNER_ID, $partner_id, Criteria::EQUAL);
}
$conv_list = self::doSelect($c);
if ($conv_list == null) {
return null;
}
foreach ($conv_list as $conv) {
// select the first conversion profile that matchs the partner
if ($conv->getPartnerId() == $partner_id) {
return $conv;
}
}
// if no conv_prof found for partner - use the global ones
return $conv_list[0];
// first profile returned
}
示例2: execute
public function execute($request)
{
parent::execute($request);
$this->permissions = array();
if (null != $this->resource->id) {
// Get term permissions for this group
$criteria = new Criteria();
$criteria->addJoin(QubitAclPermission::OBJECT_ID, QubitObject::ID, Criteria::LEFT_JOIN);
$criteria->add(QubitAclPermission::GROUP_ID, $this->resource->id);
$c1 = $criteria->getNewCriterion(QubitAclPermission::OBJECT_ID, null, Criteria::ISNULL);
$c2 = $criteria->getNewCriterion(QubitObject::CLASS_NAME, 'QubitTerm');
$c1->addOr($c2);
$criteria->add($c1);
$criteria->addAscendingOrderByColumn(QubitAclPermission::CONSTANTS);
$criteria->addAscendingOrderByColumn(QubitAclPermission::OBJECT_ID);
if (0 < count($permissions = QubitAclPermission::get($criteria))) {
$this->permissions = $permissions;
}
}
// List of actions without create or translate
$this->basicActions = QubitAcl::$ACTIONS;
unset($this->basicActions['read']);
unset($this->basicActions['translate']);
if ($request->isMethod('post')) {
$this->form->bind($request->getPostParameters());
if ($this->form->isValid()) {
$this->processForm();
$this->redirect(array($this->resource, 'module' => 'aclGroup', 'action' => 'indexTermAcl'));
}
}
}
示例3: executeSearchSchools
public function executeSearchSchools(sfWebRequest $request)
{
$this->getResponse()->setContentType('application/json');
if (strlen(trim($q = $request->getParameter('q'))) > 2) {
$c = new Criteria();
$crit = $c->getNewCriterion(OriginSchoolPeer::NAME, "%{$q}%", Criteria::LIKE);
$crit->addOr($c->getNewCriterion(OriginSchoolPeer::ADDRESS, "%{$q}%", Criteria::LIKE));
$crit->addOr($c->getNewCriterion(OriginSchoolPeer::CUE, "%{$q}%", Criteria::LIKE));
$c->add($crit);
$c->setLimit(20);
$results = array();
foreach ($matches = OriginSchoolPeer::doSelect($c) as $match) {
$results[] = array('id' => $match->getId(), 'text' => $match->__toString());
}
return $this->renderText(json_encode(array('results' => $results)));
} else {
if ($request->getParameter('id') !== null) {
$match = OriginSchoolPeer::retrieveByPK($request->getParameter('id'));
$result = null;
if ($match !== null) {
$result = array('id' => $match->getId(), 'text' => strval($match));
}
return $this->renderText(json_encode($result));
}
}
return $this->renderText('{}');
}
示例4: executeBusquedaDocente
public function executeBusquedaDocente()
{
// inicializando variables
$aDocente = array();
// tomando los datos del formulario
$txt = $this->getRequestParameter('txt');
/* $organizacion_id = $this->getUser()->getAttribute('fk_organizacion_id');
$criteria = new Criteria();
$criteria->add(DocentePeer::FK_ORGANIZACION_ID, $organizacion_id);
*/
if ($this->getRequest()->getMethod() == sfRequest::POST) {
// buscando alumnos
$criteria = new Criteria();
if ($txt) {
$cton1 = $criteria->getNewCriterion(DocentePeer::NOMBRE, "%{$txt}%", Criteria::LIKE);
$cton2 = $criteria->getNewCriterion(DocentePeer::APELLIDO, "%{$txt}%", Criteria::LIKE);
$cton1->addOr($cton2);
$criteria->add($cton1);
}
$aDocente = DocentePeer::doSelect($criteria);
if (count($aDocente) == 1) {
$this->redirect('calendario/horarioSegunDocente?id=' . $aDocente[0]->getId());
}
}
// asignando variables para ser usadas en el template
//$this->organizacion_id = $organizacion_id;
$this->txt = $txt;
$this->aDocente = $aDocente;
}
示例5: retrievePagerByUser
public static function retrievePagerByUser($user_id, $page = 1, $max = null)
{
if ($max == null) {
$max = sfConfig::get('app_pager_project_max');
}
sfContext::getInstance()->getLogger()->info('Begin project retrieval by user_id');
$c = new Criteria();
$positions = ProjectUserPeer::retrieveFilledByUserId($user_id);
$projects = array();
foreach ($positions as $position) {
$projects[] = $position->getProjectPosition()->getProjectId();
}
if (count($projects) > 0) {
$c->add(self::ID, $projects, Criteria::IN);
}
$crit0 = $c->getNewCriterion(self::CREATED_BY, $user_id);
$crit1 = $c->getNewCriterion(self::OWNER_ID, $user_id);
$crit0->addOr($crit1);
$c->add($crit0);
$pager = new sfPropelPager('Project', $max);
$pager->setCriteria($c);
$pager->setPage($page);
$pager->init();
return $pager;
}
示例6: getAllGroups
/**
* returns the groups in the given ramo (and for the given legislatura) and include the zero value, if given
*
* @param string $ramo
* @param int $legislatura
* @param string $include_zero
* @return an associative array, with id and name as key => value
* @author Guglielmo Celata
*/
public static function getAllGroups($ramo, $legislatura, $include_zero = false)
{
$c = new Criteria();
if ($ramo == 'camera') {
$c->add(OppCaricaPeer::TIPO_CARICA_ID, 1);
} else {
$c->add(OppCaricaPeer::TIPO_CARICA_ID, array(4, 5), Criteria::IN);
}
$c->addJoin(OppGruppoPeer::ID, OppCaricaHasGruppoPeer::GRUPPO_ID);
$c->addJoin(OppCaricaPeer::ID, OppCaricaHasGruppoPeer::CARICA_ID);
$c_or_leg = $c->getNewCriterion(OppCaricaPeer::LEGISLATURA, $legislatura);
$c_or_leg->addOr($c->getNewCriterion(OppCaricaPeer::LEGISLATURA, null, Criteria::ISNULL));
$c->add($c_or_leg);
$c->clearSelectColumns();
$c->addSelectColumn(OppGruppoPeer::ID);
$c->addSelectColumn(OppGruppoPeer::NOME);
$c->setDistinct();
$rs = OppGruppoPeer::doSelectRS($c);
if ($include_zero) {
$all_groups = array('0' => $include_zero);
} else {
$all_groups = array();
}
while ($rs->next()) {
$all_groups[$rs->getInt(1)] = $rs->getString(2);
}
return $all_groups;
}
示例7: earlyExecute
protected function earlyExecute()
{
$this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
$this->resource = new QubitUser();
if (isset($this->getRoute()->resource)) {
$this->resource = $this->getRoute()->resource;
}
// Always include root actor permissions
$this->actors = array(QubitActor::ROOT_ID => null);
// Get actor permissions for this group
$criteria = new Criteria();
$criteria->addJoin(QubitAclPermission::OBJECT_ID, QubitObject::ID, Criteria::LEFT_JOIN);
$criteria->add(QubitAclPermission::USER_ID, $this->resource->id);
$c1 = $criteria->getNewCriterion(QubitAclPermission::OBJECT_ID, null, Criteria::ISNULL);
$c2 = $criteria->getNewCriterion(QubitObject::CLASS_NAME, 'QubitActor');
$c1->addOr($c2);
$criteria->add($c1);
if (null !== ($permissions = QubitAclPermission::get($criteria))) {
foreach ($permissions as $item) {
$this->actors[$item->objectId][$item->action] = $item;
}
}
// List of actions without translate
$this->basicActions = QubitAcl::$ACTIONS;
unset($this->basicActions['translate']);
}
示例8: getCalendarCriterias
function getCalendarCriterias($filter, $start, $limit)
{
$Criteria = new Criteria('workflow');
$Criteria->clearSelectColumns();
$Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_UID);
if ($filter != '') {
$Criteria->add($Criteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE)));
}
$Criteria->add(CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL);
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_UID);
$oCriteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_NAME);
$oCriteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_CREATE_DATE);
$oCriteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_UPDATE_DATE);
$oCriteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_DESCRIPTION);
$oCriteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_STATUS);
if ($filter != '') {
$oCriteria->add($oCriteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE)));
}
$oCriteria->add(CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL);
$oCriteria->setLimit($limit);
$oCriteria->setOffset($start);
$criterias = array();
$criterias['COUNTER'] = $Criteria;
$criterias['LIST'] = $oCriteria;
return $criterias;
}
示例9: search
public static function search($query_string, $sf_user, $limit = 12)
{
$query_string = trim($query_string);
if (!is_null($query_string) && !empty($query_string) && '' != $query_string && strlen($query_string) > 3) {
$criteria = new Criteria();
$criteria->setIgnoreCase(true);
$criteria->setLimit($limit);
$criteria->add(SchoolYearStudentPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId());
$criteria->addJoin(SchoolYearStudentPeer::STUDENT_ID, self::ID);
$criteria->addJoin(self::PERSON_ID, PersonPeer::ID, Criteria::INNER_JOIN);
$criteria->addAscendingOrderByColumn(PersonPeer::LASTNAME);
if (is_numeric($query_string)) {
// Search by identification number
$criteria->add(PersonPeer::IDENTIFICATION_NUMBER, $query_string . '%', Criteria::LIKE);
} else {
// Search by firstname or lastname
$criterion = $criteria->getNewCriterion(PersonPeer::FIRSTNAME, $query_string . '%', Criteria::LIKE);
$criterion->addOr($criteria->getNewCriterion(PersonPeer::LASTNAME, $query_string . '%', Criteria::LIKE));
$criteria->add($criterion);
}
if ($sf_user->isPreceptor()) {
PersonalPeer::joinWithStudents($criteria, $sf_user->getGuardUser()->getId());
} elseif ($sf_user->isTeacher()) {
TeacherPeer::joinWithStudents($criteria, $sf_user->getGuardUser()->getId());
}
//FALTA HEAD PRECEPTOR
return self::doSelectActive($criteria);
}
return array();
}
示例10: execute
public function execute($request)
{
parent::execute($request);
// Always include root actor permissions
$this->actors = array(QubitActor::ROOT_ID => null);
// Get actor permissions for this resource
$criteria = new Criteria();
$criteria->addJoin(QubitAclPermission::OBJECT_ID, QubitObject::ID, Criteria::LEFT_JOIN);
$criteria->add(QubitAclPermission::GROUP_ID, $this->resource->id);
$c1 = $criteria->getNewCriterion(QubitAclPermission::OBJECT_ID, null, Criteria::ISNULL);
$c2 = $criteria->getNewCriterion(QubitObject::CLASS_NAME, 'QubitActor');
$c1->addOr($c2);
$criteria->add($c1);
if (null !== ($permissions = QubitAclPermission::get($criteria))) {
foreach ($permissions as $p) {
$this->actors[$p->objectId][$p->action] = $p;
}
}
// List of actions without translate
$this->basicActions = QubitAcl::$ACTIONS;
unset($this->basicActions['translate']);
if ($request->isMethod('post')) {
$this->form->bind($request->getPostParameters());
if ($this->form->isValid()) {
$this->processForm();
$this->redirect(array($this->resource, 'module' => 'aclGroup', 'action' => 'indexActorAcl'));
}
}
}
示例11: detectHungJobs
function detectHungJobs()
{
// optimized query to select only possibly hung jobs...
$c = new Criteria();
$cStatusRunning = $c->getNewCriterion($this->options['jobStatusColName'], JQManagedJob::STATUS_RUNNING);
$cStatusWaitAsync = $c->getNewCriterion($this->options['jobStatusColName'], JQManagedJob::STATUS_WAIT_ASYNC);
$cStatusRunning->addOr($cStatusWaitAsync);
$c->add($cStatusRunning);
$c->add($this->options['jobMaxRuntimeSecondsColName'], NULL, Criteria::ISNOTNULL);
$c->add($this->options['jobMaxRuntimeSecondsColName'], "{$this->options['jobStartDtsColName']} + ({$this->options['jobMaxRuntimeSecondsColName']}||' seconds')::interval < now()", Criteria::CUSTOM);
$possiblyHungJobs = call_user_func(array("{$this->propelClassName}Peer", 'doSelect'), $c, $this->con);
foreach ($possiblyHungJobs as $possiblyHungJob) {
// @todo This is a bit ugly; we probably need something like a JQStore::performWithMutex($jobId, $f) where we can wrap f internally in a try/catch to do this more cleanly
$this->con->beginTransaction();
try {
$mJob = $this->getWithMutex($possiblyHungJob->getJobId());
if ($mJob->isPastMaxRuntimeSeconds()) {
$mJob->retry(true);
$runningTime = time() - $mJob->getStartDts()->format('U');
print "Retrying job:{$mJob->getJobId()} after running for: {$runningTime} seconds job maxRunTimeSeconds: {$mJob->getMaxRuntimeSeconds()}\n";
}
$this->clearMutex($mJob->getJobId());
$this->con->commit();
} catch (JQStore_JobNotFoundException $e) {
// the job already finished, continue the loop
print "job not found, continue\n";
$this->abort();
continue;
} catch (Exception $e) {
$this->abort();
throw $e;
}
}
}
示例12: serversideAction
public function serversideAction()
{
$request = $this->getRequest();
if ($request->isPost()) {
//EL MAPEO DE NUESTRA TABALA
$table_map = array(0 => 'expediente_folio', 1 => 'expediente_fechainicio', 2 => 'expediente_tipo', 3 => 'expediente_consignatario', 4 => 'expediente_embarcador', 5 => 'expediente_estatus');
$post_data = $request->getPost();
//NUESTRA QUERY
$query = new \ExpedienteQuery();
$query->joinCliente()->withColumn('cliente_razonsocial');
$query->joinProveedorcliente()->withColumn('proveedorcliente_nombre');
//ORDER
if (isset($post_data['order'])) {
$order = $table_map[$post_data['order'][0]['column']];
$dir = $post_data['order'][0]['dir'];
$query->orderBy($order, $dir);
} else {
$query->orderByIdexpediente(\Criteria::DESC);
}
if (!empty($post_data['search']['value'])) {
$search = $post_data['search']['value'];
$c = new \Criteria();
$c1 = $c->getNewCriterion('expediente.expediente_folio', '%' . $search . '%', \Criteria::LIKE);
//$c2= $c->getNewCriterion('expediente.expediente_fechainicio', '%'.$search.'%', \Criteria::LIKE);
$c3 = $c->getNewCriterion('expediente.expediente_tipo', '%' . $search . '%', \Criteria::LIKE);
$c4 = $c->getNewCriterion('expediente.expediente_estatus', '%' . $search . '%', \Criteria::LIKE);
$c5 = $c->getNewCriterion('cliente.cliente_razonsocial', '%' . $search . '%', \Criteria::LIKE);
$c6 = $c->getNewCriterion('proveedorcliente.proveedorcliente_nombre', '%' . $search . '%', \Criteria::LIKE);
$c1->addOr($c3)->addOr($c4)->addOr($c5)->addOr($c6);
$query->addAnd($c1);
}
//EL TOTAL DE LA BUSQUEDA
$recordsFiltered = $query->count();
//LIMIT
$query->setOffset((int) $post_data['start']);
$query->setLimit((int) $post_data['length']);
//DAMOS EL FORMATO CORRECTO
$data = array();
$value = new \Expediente();
foreach ($query->find() as $value) {
$tmp['DT_RowId'] = $value->getIdexpediente();
$tmp['expediente_folio'] = $value->getExpedienteFolio('d/m/Y');
$tmp['expediente_fechainicio'] = $value->getExpedienteFechainicio('d/m/Y');
$tmp['expediente_tipo'] = $value->getExpedienteTipo();
$tmp['expediente_estatus'] = ucfirst($value->getExpedienteEstatus());
if ($value->getExpedienteTipo() == 'importacion') {
$tmp['expediente_consignatario'] = $value->getCliente()->getClienteRazonsocial();
$tmp['expediente_embarcador'] = $value->getProveedorcliente()->getProveedorclienteNombre();
} else {
$tmp['expediente_embarcador'] = $value->getCliente()->getClienteRazonsocial();
$tmp['expediente_consignatario'] = $value->getProveedorcliente()->getProveedorclienteNombre();
}
$tmp['expediente_options'] = '<a data-toggle="tooltip" data-placement="left" title="Editar" href="/clientes/ver/' . $value->getIdcliente() . '/expedientes/ver/' . $value->getIdexpediente() . '"><i class="fa fa-pencil"></i></a><a class="delete" data-toggle="tooltip" data-placement="left" title="Eliminar" href="javascript:void(0)"><i class="fa fa-trash-o"></i></a>';
$data[] = $tmp;
}
//El arreglo que regresamos
$json_data = array("draw" => (int) $post_data['draw'], "recordsFiltered" => $recordsFiltered, "data" => $data, "page" => $post_data['url_params']['page']);
return $this->getResponse()->setContent(json_encode($json_data));
}
}
示例13: delete
public function delete($connection = null)
{
// Cascade delete descendants
if (0 < count($children = $this->getChildren())) {
foreach ($children as $child) {
$child->delete($connection);
}
}
// Delete relations
$criteria = new Criteria();
$cton1 = $criteria->getNewCriterion(QubitRelation::OBJECT_ID, $this->id);
$cton2 = $criteria->getNewCriterion(QubitRelation::SUBJECT_ID, $this->id);
$cton1->addOr($cton2);
$criteria->add($cton1);
if (0 < count($relations = QubitRelation::get($criteria))) {
foreach ($relations as $relation) {
$relation->delete($connection);
}
}
// Delete relation to objects
$criteria = new Criteria();
$criteria->add(QubitObjectTermRelation::TERM_ID, $this->id);
if (0 < count($otRelations = QubitObjectTermRelation::get($criteria))) {
foreach ($otRelations as $otRelation) {
$otRelation->delete($connection);
}
}
parent::delete($connection);
}
示例14: getReviewsByUser
public static function getReviewsByUser($userId, $f = false, $page = 1, $numberOfResults = BaseSfReviewManager::NUM_REVIEWS)
{
$culture = sfContext::getInstance()->getUser()->getCulture();
$criteria = new Criteria();
$criteria->add(SfReviewPeer::IS_ACTIVE, true);
// Filter entities by culture. Must have 'culture' column and 'culturized' column in sf_review_type must be checked
$criteria->addJoin(SfReviewPeer::SF_REVIEW_TYPE_ID, SfReviewTypePeer::ID, Criteria::LEFT_JOIN);
$cultureCriterion = $criteria->getNewCriterion(SfReviewTypePeer::CULTURIZED, false);
$cultureCriterion->addOr($criteria->getNewCriterion(SfReviewPeer::CULTURE, $culture));
$criteria->add($cultureCriterion);
$criteria->add(SfReviewPeer::SF_GUARD_USER_ID, $userId);
$criteria->add(SfReviewPeer::ANONYMOUS, false);
$criteria->addDescendingOrderByColumn("IFNULL(" . SfReviewPeer::MODIFIED_AT . "," . SfReviewPeer::CREATED_AT . ")");
if ($f) {
if (preg_match('/\\.0/', $f)) {
$criteria->add(SfReviewPeer::SF_REVIEW_TYPE_ID, null, Criteria::ISNULL);
} else {
if (preg_match('/[0-9]/', $f)) {
$criteria->add(SfReviewPeer::SF_REVIEW_TYPE_ID, $f);
}
}
$criteria->add(SfReviewPeer::IS_ACTIVE, true);
}
$pager = new sfPropelPager('SfReview', $numberOfResults);
$pager->setCriteria($criteria);
$pager->setPage($page);
$pager->init();
return $pager;
}
示例15: retrieveByLastId
/**
* Retrieve all records larger than the id
*
* @param array $servers<SphinxLogServer>
* @param int $gap
* @param int $limit
* @param array $handledEntries
* @param PropelPDO $con the connection to use
* @return SphinxLog
*/
public static function retrieveByLastId(array $servers, $gap = 0, $limit = 1000, array $handledEntries = null, PropelPDO $con = null)
{
$criteria = new Criteria();
$criterions = null;
if (count($servers)) {
$criterions = $criteria->getNewCriterion(SphinxLogPeer::ID, null, Criteria::ISNULL);
}
foreach ($servers as $server) {
$dc = $server->getDc();
$crit = $criteria->getNewCriterion(SphinxLogPeer::ID, $server->getLastLogId() - $gap, Criteria::GREATER_THAN);
$crit->addAnd($criteria->getNewCriterion(SphinxLogPeer::DC, $dc));
if (!is_null($handledEntries)) {
$crit->addAnd($criteria->getNewCriterion(SphinxLogPeer::ID, $handledEntries[$dc], Criteria::NOT_IN));
}
$criterions->addOr($crit);
}
if ($criterions) {
$criteria->addAnd($criterions);
}
$disabledPartnerIds = kConf::get('disable_sphinx_indexing_partners', 'local', array());
if ($disabledPartnerIds) {
$criteria->add(SphinxLogPeer::PARTNER_ID, $disabledPartnerIds, Criteria::NOT_IN);
}
$criteria->addAscendingOrderByColumn(SphinxLogPeer::ID);
$criteria->setLimit($limit);
return SphinxLogPeer::doSelect($criteria, $con);
}