/** * Get criteria for Trigger * * return object */ public function getTriggerCriteria() { try { $delimiter = \DBAdapter::getStringDelimiter(); $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\TriggersPeer::TRI_UID); $criteria->addAsColumn("TRI_TITLE", "CT.CON_VALUE"); $criteria->addAsColumn("TRI_DESCRIPTION", "CD.CON_VALUE"); $criteria->addSelectColumn(\TriggersPeer::TRI_TYPE); $criteria->addSelectColumn(\TriggersPeer::TRI_WEBBOT); $criteria->addSelectColumn(\TriggersPeer::TRI_PARAM); $criteria->addAlias("CT", \ContentPeer::TABLE_NAME); $criteria->addAlias("CD", \ContentPeer::TABLE_NAME); $arrayCondition = array(); $arrayCondition[] = array(\TriggersPeer::TRI_UID, "CT.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "TRI_TITLE" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); $arrayCondition = array(); $arrayCondition[] = array(\TriggersPeer::TRI_UID, "CD.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_CATEGORY", $delimiter . "TRI_DESCRIPTION" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); return $criteria; } catch (\Exception $e) { throw $e; } }
public function getNotas($ciclolectivo_id) { $notaAlumno = array(); $notaActividad = array(); // notas del alumno $criteria = new Criteria(); $criteria->add(BoletinActividadesPeer::FK_ALUMNO_ID, $this->getId()); $criteria->add(PeriodoPeer::CALCULAR, false); $criteria->add(PeriodoPeer::FK_CICLOLECTIVO_ID, $ciclolectivo_id); $criteria->addJoin(BoletinActividadesPeer::FK_ESCALANOTA_ID, EscalanotaPeer::ID); $criteria->addJoin(BoletinActividadesPeer::FK_PERIODO_ID, PeriodoPeer::ID); $criteria->addAsColumn("boletinActividades_periodo_id", BoletinActividadesPeer::FK_PERIODO_ID); $criteria->addAsColumn("boletinActividades_actividad_id", BoletinActividadesPeer::FK_ACTIVIDAD_ID); $criteria->addAsColumn("escalanota_nombre", EscalanotaPeer::NOMBRE); $aBoletinActividades = BasePeer::doSelect($criteria); foreach ($aBoletinActividades as $boletinActividades) { $notaAlumno[$boletinActividades[0]][$boletinActividades[1]] = $boletinActividades[2]; $notaActividad[$boletinActividades[1]][$boletinActividades[0]] = $boletinActividades[2]; } $c = new Criteria(); $c->add(PeriodoPeer::FK_CICLOLECTIVO_ID, $ciclolectivo_id); $c->add(PeriodoPeer::CALCULAR, true); $periodos = PeriodoPeer::doSelect($c); foreach ($notaActividad as $act_indice => &$act) { foreach ($periodos as $periodo) { //validar que esten ok if (trim($periodo->getFormula()) != '') { list($class_formula, $parametros) = explode('|', $periodo->getFormula()); $parametros = explode(',', $parametros); //if (array_intersect($parametros,array_keys($act)) == $parametros) { sfContext::getInstance()->getLogger()->debug("estan todo slo ids"); $class_formula = "formula_{$class_formula}"; require_once sfConfig::get('sf_lib_dir') . DIRECTORY_SEPARATOR . 'formulas' . DIRECTORY_SEPARATOR . $class_formula . ".class.php"; $formula = new $class_formula(); $notas_parametros = array(); foreach ($parametros as $parametro) { if (isset($act[$parametro])) { array_push($notas_parametros, sprintf("%01.2f", str_replace(",", ".", $act[$parametro]))); } else { array_push($notas_parametros, ''); } } $nota = $formula->calcular($notas_parametros); $notaAlumno[$periodo->getId()][$act_indice] = $nota; $act[$periodo->getId()] = $nota; //} //else { // sfContext::getInstance()->getLogger()->debug('faltan parametros para la formula'); //} } else { sfContext::getInstance()->getLogger()->debug('el periodo es calculable pero no tiene una formula cargada'); } } } return $notaAlumno; }
/** * Get the email server accounts of the current workspace * * return array */ public function getEmailEventServerAccounts() { try { $criteria = new \Criteria("workflow"); $criteria->clearSelectColumns(); $criteria->addSelectColumn(\EmailServerPeer::MESS_UID); $criteria->addSelectColumn(\EmailServerPeer::MESS_FROM_MAIL); $criteria->addSelectColumn(\EmailServerPeer::MESS_ACCOUNT); $criteria->addAsColumn('UID', 'MESS_UID'); $result = \EmailServerPeer::doSelectRS($criteria); $result->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $result->next(); $accountsArray = array(); while ($aRow = $result->getRow()) { if ($aRow['MESS_UID'] != null) { if($aRow['MESS_FROM_MAIL'] == "") { $aRow['EMAIL'] = $aRow['MESS_ACCOUNT']; } else { $aRow['EMAIL'] = $aRow['MESS_FROM_MAIL']; } $accountsArray[] = array_change_key_case($aRow, CASE_LOWER); } $result->next(); } return $accountsArray; } catch (\Exception $e) { throw $e; } }
public static function getKshowRoughcutCount(array $kuser_id_list) { $c = new Criteria(); $c->add(entryPeer::TYPE, entryType::MIX); $c->add(entryPeer::KSHOW_ID, $kuser_id_list, Criteria::IN); $c->addSelectColumn(entryPeer::KSHOW_ID); $c->addAsColumn('cnt', 'COUNT(' . entryPeer::KSHOW_ID . ')'); $c->addGroupByColumn(entryPeer::KSHOW_ID); $rs = entryPeer::doSelectStmt($c); $kusers_roughcuts = array(); $res = $rs->fetchAll(); foreach ($res as $record) { $id = $record[0]; $cnt = $record[1]; $kusers_roughcuts[$id] = $cnt; } // // old code from doSelectRs // while($rs->next()) // { // $id= $rs->getInt(1); // $cnt = $rs->getInt(2); // $kusers_roughcuts[$id]=$cnt; // } $rs->close(); return $kusers_roughcuts; }
/** * Assign fallback values for each column in the $fallbackClassName table * * @param Criteria $criteria * @param string $fallbackClass name of Prople class for table with desired fallback columns * @return Criteria $criteria object withi extra calculated fallback columns */ public static function addFallbackColumns($criteria, $fallbackClassName) { $tableMap = eval('return new ' . substr($fallbackClassName, 5) . 'TableMap;'); // Loop through table columns and add fallback calculated fields to criteria foreach ($tableMap->getColumns() as $col) { $criteria->addAsColumn($col->getColumnName(), self::getfallbackCaseStmt($col->getColumnName())); } return $criteria; }
/** * Get list for Events * @var string $pro_uid. Uid for Process * @var string $filter. * @var string $evn_uid. Uid for Process * * @access public * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia * * @return array */ public function getEvents($pro_uid, $filter = '', $evn_uid = '') { $pro_uid = $this->validateProUid($pro_uid); if ($evn_uid != '') { $evn_uid = $this->validateEvnUid($evn_uid); } $oProcess = new \Process(); if (!$oProcess->processExists($pro_uid)) { throw new \Exception(\G::LoadTranslation("ID_PROCESS_NOT_EXIST", array('pro_uid', $pro_uid))); } $sDelimiter = \DBAdapter::getStringDelimiter(); $oCriteria = new \Criteria('workflow'); $oCriteria->addSelectColumn(\EventPeer::EVN_UID); $oCriteria->addSelectColumn(\EventPeer::EVN_ACTION); $oCriteria->addSelectColumn(\EventPeer::EVN_STATUS); $oCriteria->addSelectColumn(\EventPeer::EVN_WHEN_OCCURS); $oCriteria->addSelectColumn(\EventPeer::EVN_RELATED_TO); $oCriteria->addAsColumn('EVN_DESCRIPTION', \ContentPeer::CON_VALUE); $aConditions = array(); $aConditions[] = array(\EventPeer::EVN_UID, \ContentPeer::CON_ID); $aConditions[] = array(\ContentPeer::CON_CATEGORY, $sDelimiter . 'EVN_DESCRIPTION' . $sDelimiter); $aConditions[] = array(\ContentPeer::CON_LANG, $sDelimiter . SYS_LANG . $sDelimiter); $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN); $oCriteria->add(\EventPeer::PRO_UID, $pro_uid); if ($evn_uid != '') { $oCriteria->add(\EventPeer::EVN_UID, $evn_uid); } switch ($filter) { case 'message': $oCriteria->add(\EventPeer::EVN_ACTION, "SEND_MESSAGE"); break; case 'conditional': $oCriteria->add(\EventPeer::EVN_ACTION, "EXECUTE_CONDITIONAL_TRIGGER"); break; case 'multiple': $oCriteria->add(\EventPeer::EVN_ACTION, "EXECUTE_TRIGGER"); break; } $eventsArray = array(); $oDataset = \EventPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oEvent = new \Event(); $aFields = $oEvent->load($aRow['EVN_UID']); $aRow = array_merge($aRow, $aFields); $eventsArray[] = array_change_key_case($aRow, CASE_LOWER); $oDataset->next(); } if ($evn_uid != '' && empty($eventsArray)) { throw new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST")); } elseif ($evn_uid != '' && !empty($eventsArray)) { return current($eventsArray); } return $eventsArray; }
public static function retrieveTotalsize(Criteria $criteria = null) { if (is_null($criteria)) { $criteria = new Criteria(); } $criteria->addAsColumn('total', "SUM(" . self::SIZE . ")"); $stmt = self::doSelectStmt($criteria); $row = $stmt->fetch(); return $row['total']; }
/** * * @param string $lat_col_name * @param string $lng_col_name * @param float $lat * @param float $lng * @param Criteria $criteria * @return Criteria * @author fabriceb * @since Sep 9, 2009 */ public static function criteriaOrderByDistance($lat_col_name, $lng_col_name, $lat, $lng, $criteria = null) { if (is_null($criteria)) { $criteria = new Criteria(); } $distance_query = '(POW(( %s - %F ),2) + POW(( %s - %F ),2))'; $distance_query = sprintf($distance_query, $lat_col_name, $lat, $lng_col_name, $lng); $criteria->addAsColumn('distance', $distance_query); $criteria->addAscendingOrderByColumn('distance'); return $criteria; }
public function testCreateSelectSqlPart() { Propel::setDb('oracle', new DBOracle()); $db = Propel::getDB(); $c = new Criteria(); $c->addSelectColumn(BookPeer::ID); $c->addAsColumn('book_ID', BookPeer::ID); $fromClause = array(); $selectSql = $db->createSelectSqlPart($c, $fromClause); $this->assertEquals('SELECT book.ID, book.ID AS book_ID', $selectSql, 'createSelectSqlPart() returns a SQL SELECT clause with both select and as columns'); $this->assertEquals(array('book'), $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause'); }
public function getCriteriaDBSList($sProcessUID) { $sDelimiter = DBAdapter::getStringDelimiter(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(DbSourcePeer::DBS_UID); $oCriteria->addSelectColumn(DbSourcePeer::PRO_UID); $oCriteria->addSelectColumn(DbSourcePeer::DBS_TYPE); $oCriteria->addAsColumn("DBS_SERVER", "CASE WHEN " . DbSourcePeer::DBS_TYPE . " = 'oracle' AND " . DbSourcePeer::DBS_CONNECTION_TYPE . " = 'TNS' THEN CONCAT('[', " . DbSourcePeer::DBS_TNS . ", ']') ELSE " . DbSourcePeer::DBS_SERVER . " END"); $oCriteria->addAsColumn("DBS_DATABASE_NAME", "CASE WHEN " . DbSourcePeer::DBS_TYPE . " = 'oracle' AND " . DbSourcePeer::DBS_CONNECTION_TYPE . " = 'TNS' THEN CONCAT('[', " . DbSourcePeer::DBS_TNS . ", ']') ELSE " . DbSourcePeer::DBS_DATABASE_NAME . " END"); $oCriteria->addSelectColumn(DbSourcePeer::DBS_USERNAME); $oCriteria->addSelectColumn(DbSourcePeer::DBS_PASSWORD); $oCriteria->addSelectColumn(DbSourcePeer::DBS_PORT); $oCriteria->addAsColumn('DBS_DESCRIPTION', 'C.CON_VALUE'); $oCriteria->addAlias('C', 'CONTENT'); $aConditions = array(); $aConditions[] = array(DbSourcePeer::DBS_UID, 'C.CON_ID'); $aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'DBS_DESCRIPTION' . $sDelimiter); $aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(DbSourcePeer::PRO_UID, $sProcessUID); return $oCriteria; }
/** * Execute digitalobject list action * * @param sfWebRequest $request */ public function execute($request) { // Build funky join query to get a count of top level digital objects // for each media type (term) $criteria = new Criteria(); $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::MEDIA_TYPE_ID); $criteria->addJoin(QubitTerm::ID, QubitDigitalObject::MEDIA_TYPE_ID, Criteria::LEFT_JOIN); $criteria->addAsColumn('hits', 'COUNT(' . QubitDigitalObject::ID . ')'); $criteria->addGroupByColumn(QubitTerm::ID); // Add I18n fallback $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitTerm'); $criteria->addAscendingOrderByColumn('name'); // Filter drafts $criteria->addJoin(QubitDigitalObject::INFORMATION_OBJECT_ID, QubitInformationObject::ID); $criteria = QubitAcl::addFilterDraftsCriteria($criteria); $this->terms = QubitTerm::get($criteria); }
public static function getFrontPagePager($page) { $pager = new sfPropelPager('Question', sfConfig::get('app_pager_homepage_max')); $c = new Criteria(); $c->addAsColumn('count', "count(" . InterestPeer::USER_ID . ")"); $c->addJoin(InterestPeer::QUESTION_ID, QuestionPeer::ID); $c->addGroupByColumn(InterestPeer::QUESTION_ID); $c->addDescendingOrderByColumn('count'); $c->addDescendingOrderByColumn(self::CREATED_AT); $c->add(InterestPeer::CREATED_AT, time() - 86400 * 10, Criteria::GREATER_THAN); $c = self::addPermanentTagToCriteria($c); $pager->setCriteria($c); $pager->setPage($page); $pager->setPeerMethod('doSelectJoinUser'); $pager->init(); return $pager; }
public function getCalendarList ($onlyActive = false, $arrayMode = false) { $Criteria = new Criteria( 'workflow' ); $Criteria->clearSelectColumns(); $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID ); $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME ); $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE ); $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS ); // $Criteria->addAsColumn('DELETABLE', "IF (CALENDAR_UID <> '00000000000000000000000000000001', '".G::LoadTranslation('ID_DELETE')."','') "); $Criteria->addAsColumn( 'DELETABLE', "CASE WHEN CALENDAR_UID <> '00000000000000000000000000000001' THEN '" . G::LoadTranslation( 'ID_DELETE' ) . "' ELSE '' END " ); // Note: This list doesn't show deleted items (STATUS = DELETED) if ($onlyActive) { // Show only active. Used on assignment lists $Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, "ACTIVE", CRITERIA::EQUAL ); } else { // Show Active and Inactive calendars. USed in main list $Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, array ("ACTIVE","INACTIVE"), CRITERIA::IN ); } $Criteria->add( calendarDefinitionPeer::CALENDAR_UID, "xx", CRITERIA::NOT_EQUAL ); if (! $arrayMode) { return $Criteria; } else { $oDataset = calendarDefinitionPeer::doSelectRS( $Criteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); $calendarA = array (0 => 'dummy'); $calendarCount = 0; while (is_array( $aRow = $oDataset->getRow() )) { $calendarCount ++; $calendarA[$calendarCount] = $aRow; $oDataset->next(); } $return['criteria'] = $Criteria; $return['array'] = $calendarA; return $return; } }
public function getCriteriaDBSList($sProcessUID) { $sDelimiter = DBAdapter::getStringDelimiter(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(DbSourcePeer::DBS_UID); $oCriteria->addSelectColumn(DbSourcePeer::PRO_UID); $oCriteria->addSelectColumn(DbSourcePeer::DBS_TYPE); $oCriteria->addSelectColumn(DbSourcePeer::DBS_SERVER); $oCriteria->addSelectColumn(DbSourcePeer::DBS_DATABASE_NAME); $oCriteria->addSelectColumn(DbSourcePeer::DBS_USERNAME); $oCriteria->addSelectColumn(DbSourcePeer::DBS_PASSWORD); $oCriteria->addSelectColumn(DbSourcePeer::DBS_PORT); $oCriteria->addAsColumn('DBS_DESCRIPTION', 'C.CON_VALUE'); $oCriteria->addAlias('C', 'CONTENT'); $aConditions = array(); $aConditions[] = array(DbSourcePeer::DBS_UID, 'C.CON_ID'); $aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'DBS_DESCRIPTION' . $sDelimiter); $aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(DbSourcePeer::PRO_UID, $sProcessUID); return $oCriteria; }
/** * Get SubProcess in Process * * return object */ public function getSubprocesss($pro_uid, $tas_uid) { try { $pro_uid = $this->validateProUid($pro_uid); $tas_uid = $this->validateTasUid($tas_uid); $oCriteria = new \Criteria('workflow'); $del = \DBAdapter::getStringDelimiter(); $oCriteria->add(SubProcessPeer::PRO_PARENT, $pro_uid); $oCriteria->add(SubProcessPeer::TAS_PARENT, $tas_uid); $oCriteria->addAsColumn('CON_VALUE', 'C1.CON_VALUE', 'CON_TITLE'); $oCriteria->addAlias("C1", 'CONTENT'); $tasTitleConds = array(); $tasTitleConds[] = array(SubProcessPeer::TAS_PARENT, 'C1.CON_ID'); $tasTitleConds[] = array('C1.CON_CATEGORY', $del . 'TAS_TITLE' . $del); $tasTitleConds[] = array('C1.CON_LANG', $del . SYS_LANG . $del); $oCriteria->addJoinMC($tasTitleConds, \Criteria::LEFT_JOIN); $oDataset = SubProcessPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aRow = $oDataset->getRow(); $aRow = array_change_key_case($aRow, CASE_LOWER); $response['spr_uid'] = $aRow['sp_uid']; $response['spr_pro_parent'] = $aRow['pro_parent']; $response['spr_tas_parent'] = $aRow['tas_parent']; $response['spr_pro'] = $aRow['pro_uid']; $response['spr_tas'] = $aRow['tas_uid']; $response['spr_name'] = $aRow['con_value']; $response['spr_synchronous'] = $aRow['sp_synchronous']; $response['spr_variables_out'] = unserialize($aRow['sp_variables_out']); if ((int) $response['spr_synchronous'] === 1) { $response['spr_variables_in'] = unserialize($aRow['sp_variables_in']); } return $response; } catch (\Exception $e) { throw $e; } }
/** * This function looks for an special case it has a condition * * * @name generatedReport2_filter * * @param string $from * @param string $to * @param string $startedby * @return object */ function generatedReport2_filter($from, $to, $startedby) { $this->reportsPatch(); require_once 'classes/model/AppDelegation.php'; require_once 'classes/model/Application.php'; require_once 'classes/model/Users.php'; $oCriteria = new Criteria('workflow'); $del = DBAdapter::getStringDelimiter(); $oCriteria->addSelectColumn(AppDelegationPeer::PRO_UID); $oCriteria->addAsColumn("MIN", "MIN(" . AppDelegationPeer::DEL_DURATION . ")"); $oCriteria->addAsColumn("MAX", "MAX(" . AppDelegationPeer::DEL_DURATION . ")"); $oCriteria->addAsColumn('PRO_TITLE', 'C1.CON_VALUE'); $oCriteria->addAlias("C1", 'CONTENT'); $proTitleConds = array(); $proTitleConds[] = array(AppDelegationPeer::PRO_UID, 'C1.CON_ID'); $proTitleConds[] = array('C1.CON_CATEGORY', $del . 'PRO_TITLE' . $del); $proTitleConds[] = array('C1.CON_LANG', $del . SYS_LANG . $del); $oCriteria->addJoinMC($proTitleConds, Criteria::LEFT_JOIN); $oCriteria->addGroupByColumn(AppDelegationPeer::PRO_UID); $oCriteria->addGroupByColumn('C1.CON_VALUE'); $oCriteria->add($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $from . ' 00:00:00', Criteria::GREATER_EQUAL)->addAnd($oCriteria->getNewCriterion(AppDelegationPeer::DEL_INIT_DATE, $to . ' 23:59:59', Criteria::LESS_EQUAL))); if ($startedby != '') { $oCriteria->add(AppDelegationPeer::USR_UID, $startedby); } $oDataset = AppDelegationPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $month = date('Y-m-d', mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"))); $lastmonth = date('Y-m-d', mktime(0, 0, 0, date("m") - 2, date("d"), date("Y"))); $day = mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")); $lastday = mktime(0, 0, 0, date("m"), date("d") - 2, date("Y")); $aProcess[] = array('PRO_UID' => 'char', 'PRO_TITLE' => 'char', 'CANTCASES' => 'integer', 'MIN' => 'float', 'MAX' => 'float', 'CASELASTMONTH' => 'integer', 'CASELASTDAY' => 'integer'); while ($aRow = $oDataset->getRow()) { $oCriteria2 = new Criteria('workflow'); $oCriteria2->addSelectColumn(ApplicationPeer::PRO_UID); $oCriteria2->addAsColumn("CANTCASES", "COUNT(*)"); $oCriteria2->add(ApplicationPeer::PRO_UID, $aRow['PRO_UID']); if ($startedby != '') { $oCriteria2->add(ApplicationPeer::APP_INIT_USER, $startedby); } $oCriteria2->addGroupByColumn(ApplicationPeer::PRO_UID); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow2 = $oDataset2->getRow(); $cant = $aRow2['CANTCASES']; $oCriteria2 = new Criteria('workflow'); $oCriteria2->addSelectColumn(ApplicationPeer::PRO_UID); $oCriteria2->addAsColumn("CANTCASES", "COUNT(*)"); $oCriteria2->add(ApplicationPeer::PRO_UID, $aRow['PRO_UID']); $oCriteria2->add(ApplicationPeer::APP_INIT_DATE, $lastmonth, Criteria::GREATER_EQUAL); $oCriteria2->add(ApplicationPeer::APP_INIT_DATE, $month, Criteria::LESS_EQUAL); if ($startedby != '') { $oCriteria2->add(ApplicationPeer::APP_INIT_USER, $startedby); } $oCriteria2->addGroupByColumn(ApplicationPeer::PRO_UID); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow2 = $oDataset2->getRow(); $cant1 = $aRow2['CANTCASES']; $oCriteria2 = new Criteria('workflow'); $oCriteria2->addSelectColumn(ApplicationPeer::PRO_UID); $oCriteria2->addAsColumn("CANTCASES", "COUNT(*)"); $oCriteria2->add(ApplicationPeer::PRO_UID, $aRow['PRO_UID']); $oCriteria2->add(ApplicationPeer::APP_INIT_DATE, $lastday, Criteria::GREATER_EQUAL); $oCriteria2->add(ApplicationPeer::APP_INIT_DATE, $day, Criteria::LESS_EQUAL); if ($startedby != '') { $oCriteria2->add(ApplicationPeer::APP_INIT_USER, $startedby); } $oCriteria2->addGroupByColumn(ApplicationPeer::PRO_UID); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow2 = $oDataset2->getRow(); $cant2 = $aRow2['CANTCASES']; /*$aProcess[] = array('PRO_UID' => $aRow['PRO_UID'], 'PRO_TITLE' => $aRow['PRO_TITLE'], 'CANTCASES' => $cant, 'CASELASTMONTH' => $cant1, 'CASELASTDAY' => $cant2 );*/ $aProcess[] = array('PRO_UID' => $aRow['PRO_UID'], 'PRO_TITLE' => $aRow['PRO_TITLE'], 'CANTCASES' => $cant, 'MIN' => number_format($aRow['MIN'], 2), 'MAX' => number_format($aRow['MAX'], 2), 'CASELASTMONTH' => number_format($cant1, 2), 'CASELASTDAY' => number_format($cant2, 2)); $oDataset->next(); } global $_DBArray; $_DBArray['reports'] = $aProcess; $_SESSION['_DBArray'] = $_DBArray; G::LoadClass('ArrayPeer'); $oCriteria = new Criteria('dbarray'); $oCriteria->setDBArrayTable('reports'); return $oCriteria; }
/** * @expectedException PropelException */ public function testMergeWithAsColumnsThrowsException() { $c1 = new Criteria(); $c1->addAsColumn('foo', BookPeer::TITLE); $c2 = new Criteria(); $c2->addAsColumn('foo', BookPeer::ID); $c1->mergeWith($c2); }
private function _getTodosLosAlumnos($establecimiento_id = '', $txt = '') { $aAlumno = array(); $criteria = new Criteria(); if ($establecimiento_id) { $criteria->add(AlumnoPeer::FK_ESTABLECIMIENTO_ID, $establecimiento_id); } if ($txt) { $cton1 = $criteria->getNewCriterion(AlumnoPeer::NOMBRE, "%{$txt}%", Criteria::LIKE); $cton2 = $criteria->getNewCriterion(AlumnoPeer::APELLIDO, "%{$txt}%", Criteria::LIKE); $cton1->addOr($cton2); $criteria->add($cton1); } $criteria->addAsColumn("alumno_id", AlumnoPeer::ID); $criteria->addAsColumn("alumno_nombre", AlumnoPeer::NOMBRE); $criteria->addAsColumn("alumno_apellido", AlumnoPeer::APELLIDO); $alumnos = BasePeer::doSelect($criteria); foreach ($alumnos as $alumno) { $aAlumno[] = (object) array('alumno_id' => $alumno[0], 'alumno_nombre' => $alumno[1], 'alumno_apellido' => $alumno[2]); } return $aAlumno; }
function getLastLoginAllUsers() { $c = new Criteria(); $c->addSelectColumn(LoginLogPeer::USR_UID); $c->addAsColumn('LAST_LOGIN', 'MAX(LOG_INIT_DATE)'); $c->addGroupByColumn(LoginLogPeer::USR_UID); $Dat = LoginLogPeer::doSelectRS($c); $Dat->setFetchmode(ResultSet::FETCHMODE_ASSOC); $aRows = array(); while ($Dat->next()) { $row = $Dat->getRow(); $aRows[$row['USR_UID']] = $row['LAST_LOGIN']; } return $aRows; }
public function getTotalCasesByAllUsers() { $oCriteria = new Criteria("workflow"); $oCriteria->addSelectColumn(AppCacheViewPeer::USR_UID); $oCriteria->addAsColumn("CNT", "COUNT(DISTINCT(APP_UID))"); $oCriteria->addGroupByColumn(AppCacheViewPeer::USR_UID); $dat = AppCacheViewPeer::doSelectRS($oCriteria); $dat->setFetchmode(ResultSet::FETCHMODE_ASSOC); $aRows = array(); while ($dat->next()) { $row = $dat->getRow(); $aRows[$row["USR_UID"]] = $row["CNT"]; } return $aRows; }
/** * Get criteria for InputDocument * * return object */ public function getInputDocumentCriteria() { try { $delimiter = \DBAdapter::getStringDelimiter(); $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_UID); $criteria->addAsColumn("INP_DOC_TITLE", "CT.CON_VALUE"); $criteria->addAsColumn("INP_DOC_DESCRIPTION", "CD.CON_VALUE"); $criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_FORM_NEEDED); $criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_ORIGINAL); $criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_PUBLISHED); $criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_VERSIONING); $criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_DESTINATION_PATH); $criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_TAGS); $criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_TYPE_FILE); $criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_MAX_FILESIZE); $criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_MAX_FILESIZE_UNIT); $criteria->addAlias("CT", \ContentPeer::TABLE_NAME); $criteria->addAlias("CD", \ContentPeer::TABLE_NAME); $arrayCondition = array(); $arrayCondition[] = array(\InputDocumentPeer::INP_DOC_UID, "CT.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "INP_DOC_TITLE" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); $arrayCondition = array(); $arrayCondition[] = array(\InputDocumentPeer::INP_DOC_UID, "CD.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_CATEGORY", $delimiter . "INP_DOC_DESCRIPTION" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); return $criteria; } catch (\Exception $e) { throw $e; } }
public function getAdvancedSearch($sCase, $sProcess, $sTask, $sCurrentUser, $sSentby, $sLastModFrom, $sLastModTo, $sStatus, $permisse, $userlogged, $aSupervisor) { $sTypeList = ''; $sUIDUserLogged = ''; $c = new Criteria('workflow'); $c->clearSelectColumns(); $c->addSelectColumn(ApplicationPeer::APP_UID); $c->addSelectColumn(ApplicationPeer::APP_NUMBER); $c->addSelectColumn(ApplicationPeer::APP_UPDATE_DATE); $c->addSelectColumn(AppDelegationPeer::DEL_PRIORITY); //$c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE); $c->addAsColumn( 'DEL_TASK_DUE_DATE', " IF (" . AppDelegationPeer::DEL_TASK_DUE_DATE . " <= NOW(), CONCAT('<span style=\'color:red\';>', " . AppDelegationPeer::DEL_TASK_DUE_DATE . ", '</span>'), " . AppDelegationPeer::DEL_TASK_DUE_DATE . ") "); $c->addSelectColumn(AppDelegationPeer::DEL_INDEX); $c->addSelectColumn(AppDelegationPeer::TAS_UID); $c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE); $c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE); $c->addSelectColumn(UsersPeer::USR_UID); $c->addAsColumn('APP_CURRENT_USER', "CONCAT(USERS.USR_LASTNAME, ' ', USERS.USR_FIRSTNAME)"); $c->addSelectColumn(ApplicationPeer::APP_STATUS); $c->addAsColumn('APP_TITLE', 'APP_TITLE.CON_VALUE'); $c->addAsColumn('APP_PRO_TITLE', 'PRO_TITLE.CON_VALUE'); $c->addAsColumn('APP_TAS_TITLE', 'TAS_TITLE.CON_VALUE'); //$c->addAsColumn('APP_DEL_PREVIOUS_USER', 'APP_LAST_USER.USR_USERNAME'); $c->addAsColumn( 'APP_DEL_PREVIOUS_USER', "CONCAT(APP_LAST_USER.USR_LASTNAME, ' ', APP_LAST_USER.USR_FIRSTNAME)" ); $c->addAlias("APP_TITLE", 'CONTENT'); $c->addAlias("PRO_TITLE", 'CONTENT'); $c->addAlias("TAS_TITLE", 'CONTENT'); $c->addAlias("APP_PREV_DEL", 'APP_DELEGATION'); $c->addAlias("APP_LAST_USER", 'USERS'); $c->addJoin(ApplicationPeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::LEFT_JOIN); $c->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN); $appThreadConds[] = array(ApplicationPeer::APP_UID, AppThreadPeer::APP_UID); $appThreadConds[] = array(AppDelegationPeer::DEL_INDEX, AppThreadPeer::DEL_INDEX); $c->addJoinMC($appThreadConds, Criteria::LEFT_JOIN); $c->addJoin(AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); $del = DBAdapter::getStringDelimiter(); $appTitleConds = array(); $appTitleConds[] = array(ApplicationPeer::APP_UID, 'APP_TITLE.CON_ID'); $appTitleConds[] = array('APP_TITLE.CON_CATEGORY', $del . 'APP_TITLE' . $del); $appTitleConds[] = array('APP_TITLE.CON_LANG', $del . SYS_LANG . $del); $c->addJoinMC($appTitleConds, Criteria::LEFT_JOIN); $proTitleConds = array(); $proTitleConds[] = array(ApplicationPeer::PRO_UID, 'PRO_TITLE.CON_ID'); $proTitleConds[] = array('PRO_TITLE.CON_CATEGORY', $del . 'PRO_TITLE' . $del); $proTitleConds[] = array('PRO_TITLE.CON_LANG', $del . SYS_LANG . $del); $c->addJoinMC($proTitleConds, Criteria::LEFT_JOIN); $tasTitleConds = array(); $tasTitleConds[] = array(AppDelegationPeer::TAS_UID, 'TAS_TITLE.CON_ID'); $tasTitleConds[] = array('TAS_TITLE.CON_CATEGORY', $del . 'TAS_TITLE' . $del); $tasTitleConds[] = array('TAS_TITLE.CON_LANG', $del . SYS_LANG . $del); $c->addJoinMC($tasTitleConds, Criteria::LEFT_JOIN); $prevConds = array(); $prevConds[] = array(ApplicationPeer::APP_UID, 'APP_PREV_DEL.APP_UID'); $prevConds[] = array('APP_PREV_DEL.DEL_INDEX', AppDelegationPeer::DEL_PREVIOUS); $c->addJoinMC($prevConds, Criteria::LEFT_JOIN); $usrConds = array(); $usrConds[] = array('APP_PREV_DEL.USR_UID', 'APP_LAST_USER.USR_UID'); $c->addJoinMC($usrConds, Criteria::LEFT_JOIN); $c->add(TaskPeer::TAS_TYPE, 'SUBPROCESS', Criteria::NOT_EQUAL); $c->add( $c->getNewCriterion(AppThreadPeer::APP_THREAD_STATUS, 'OPEN')-> addOr($c->getNewCriterion(ApplicationPeer::APP_STATUS, 'COMPLETED')-> addAnd($c->getNewCriterion(AppDelegationPeer::DEL_PREVIOUS, 0))) ); if ($sCase != '') { $c->add(ApplicationPeer::APP_NUMBER, $sCase); } if ($sProcess != '') { $c->add(ApplicationPeer::PRO_UID, $sProcess); } if ($sTask != '' && $sTask != "0" && $sTask != 0) { $c->add(AppDelegationPeer::TAS_UID, $sTask); } if ($sCurrentUser != '') { $c->add(ApplicationPeer::APP_CUR_USER, $sCurrentUser); } if ($sSentby != '') { $c->add('APP_PREV_DEL.USR_UID', $sSentby); } if ($sLastModFrom != '0000-00-00' && $sLastModTo != '0000-00-00' && $sLastModFrom != '' && $sLastModTo != '') { $c->add( $c->getNewCriterion(ApplicationPeer::APP_UPDATE_DATE, $sLastModFrom . ' 00:00:00', Criteria::GREATER_EQUAL)-> addAnd($c->getNewCriterion(ApplicationPeer::APP_UPDATE_DATE, $sLastModTo . ' 23:59:59', Criteria::LESS_EQUAL)) ); } if ($sStatus != '') { if ($sStatus != 'gral') { $c->add(ApplicationPeer::APP_STATUS, $sStatus); } } if ($permisse != 0) { $c->add( $c->getNewCriterion(AppDelegationPeer::USR_UID, $userlogged)-> addOr($c->getNewCriterion(AppDelegationPeer::PRO_UID, $aSupervisor, Criteria::IN)) ); } $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER); return $c; }
private static function getObjectsInPeriod($object_peer, $period_in_seconds = 3600, $period_text = "1 hour", $limit = 30, $last_id = null) { if ($period_in_seconds < 1) { $period_in_seconds = 1; } $period_clause = "ceil(UNIX_TIMESTAMP(created_at)/{$period_in_seconds})"; $c = new Criteria(); $c->addSelectColumn(self::get($object_peer, "id")); $c->addSelectColumn(self::get($object_peer, "created_at")); $c->addAsColumn("'{$period_text}'", $period_clause); $c->addAsColumn("'obj count'", "count(1)"); $c->add(self::get($object_peer, "partner_id"), 5, Criteria::NOT_EQUAL); $c->addGroupByColumn($period_clause); $c->addDescendingOrderByColumn(self::get($object_peer, "created_at")); // TODO - change to ID $c->setLimit($limit); $rs = $object_peer->doSelectStmt($c); $stats = array(); $res = $rs->fetchAll(); foreach ($res as $record) { $row = array($record[0], $record[1], $record[2], $record[3]); $stats[] = $row; } // // old code from doSelectRs // while($rs->next()) // { // $row = array ( $rs->getString(1) , $rs->getTimestamp(2) , $rs->getInt(3) , $rs->getInt(4)); // $stats[] = $row; // } $rs->close(); return $stats; }
/** * Return a single Adhoc user or group assigned to an activity * * @param string $sProcessUID {@min 32} {@max 32} * @param string $sTaskUID {@min 32} {@max 32} * @param string $sAssigneeUID {@min 32} {@max 32} * * return array * * @access public */ public function getTaskAdhocAssignee($sProcessUID, $sTaskUID, $sAssigneeUID) { try { Validator::proUid($sProcessUID, '$prj_uid'); $this->validateActUid($sTaskUID); $iType = 2; $aUsers = array(); $sDelimiter = \DBAdapter::getStringDelimiter(); $oCriteria = new \Criteria('workflow'); $oCriteria->addAsColumn('GRP_TITLE', 'C.CON_VALUE'); $oCriteria->addSelectColumn(\TaskUserPeer::TAS_UID); $oCriteria->addSelectColumn(\TaskUserPeer::USR_UID); $oCriteria->addSelectColumn(\TaskUserPeer::TU_TYPE); $oCriteria->addSelectColumn(\TaskUserPeer::TU_RELATION); $oCriteria->addAlias('C', 'CONTENT'); $aConditions = array(); $aConditions[] = array(\TaskUserPeer::USR_UID, 'C.CON_ID'); $aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'GRP_TITLE' . $sDelimiter); $aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter); $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN); $oCriteria->add(\TaskUserPeer::USR_UID, $sAssigneeUID); $oCriteria->add(\TaskUserPeer::TAS_UID, $sTaskUID); $oCriteria->add(\TaskUserPeer::TU_TYPE, $iType); $oCriteria->add(\TaskUserPeer::TU_RELATION, 2); $oDataset = \TaskUserPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $c = 0; $oTasks = new \Tasks(); $aAux = $oTasks->getGroupsOfTask($sTaskUID, 2); $aUIDS1 = array(); foreach ($aAux as $aGroup) { $aUIDS1[] = $aGroup['GRP_UID']; } $criteria = new \Criteria('workflow'); $criteria->addSelectColumn(\GroupwfPeer::GRP_UID); $criteria->addSelectColumn(\GroupwfPeer::GRP_STATUS); $criteria->addSelectColumn(\GroupwfPeer::GRP_UX); $criteria->addAsColumn('GRP_TITLE', \ContentPeer::CON_VALUE); $criteria->addJoin(\GroupwfPeer::GRP_UID, \ContentPeer::CON_ID, \Criteria::LEFT_JOIN); $criteria->add(\ContentPeer::CON_CATEGORY, 'GRP_TITLE'); $criteria->add(\ContentPeer::CON_LANG, SYS_LANG); $criteria->add(\GroupwfPeer::GRP_UID, $sAssigneeUID); $criteria->addAscendingOrderByColumn(\ContentPeer::CON_VALUE); $oDataset = \GroupwfPeer::doSelectRS($criteria); $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $groups = array(); while ($oDataset->next()) { $groups[] = $oDataset->getRow(); } $result = array('rows' => $groups); foreach ($result['rows'] as $results) { if (in_array($results['GRP_UID'], $aUIDS1)) { $c++; $oCriteria = new \Criteria('workflow'); $oCriteria->addSelectColumn('COUNT(*) AS MEMBERS_NUMBER'); $oCriteria->add(\GroupUserPeer::GRP_UID, $results['GRP_UID']); $oDataset2 = \GroupUserPeer::doSelectRS($oCriteria); $oDataset2->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow2 = $oDataset2->getRow(); $aUsers[] = array('ada_uid' => $results['GRP_UID'], 'ada_name' => !isset($aRow2['GROUP_INACTIVE']) ? $results['GRP_TITLE'] . ' (' . $aRow2['MEMBERS_NUMBER'] . ' ' . ((int) $aRow2['MEMBERS_NUMBER'] == 1 ? \G::LoadTranslation('ID_USER') : \G::LoadTranslation('ID_USERS')) . ')' . '' : $results['GRP_TITLE'] . ' ' . $aRow2['GROUP_INACTIVE'], 'ada_lastname' => "", 'ada_username' => "", 'ada_type' => "group"); } } $oCriteria = new \Criteria('workflow'); $oCriteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME); $oCriteria->addSelectColumn(\UsersPeer::USR_LASTNAME); $oCriteria->addSelectColumn(\UsersPeer::USR_USERNAME); $oCriteria->addSelectColumn(\UsersPeer::USR_EMAIL); $oCriteria->addSelectColumn(\TaskUserPeer::TAS_UID); $oCriteria->addSelectColumn(\TaskUserPeer::USR_UID); $oCriteria->addSelectColumn(\TaskUserPeer::TU_TYPE); $oCriteria->addSelectColumn(\TaskUserPeer::TU_RELATION); $oCriteria->addJoin(\TaskUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN); $oCriteria->add(\TaskUserPeer::USR_UID, $sAssigneeUID); $oCriteria->add(\TaskUserPeer::TAS_UID, $sTaskUID); $oCriteria->add(\TaskUserPeer::TU_TYPE, $iType); $oCriteria->add(\TaskUserPeer::TU_RELATION, 1); $oDataset = \TaskUserPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aUsers = array('ada_uid' => $aRow['USR_UID'], 'ada_name' => $aRow['USR_FIRSTNAME'], 'ada_lastname' => $aRow['USR_LASTNAME'], 'ada_username' => $aRow['USR_USERNAME'], 'ada_type' => "user"); $oDataset->next(); } if (empty($aUsers)) { throw new \Exception(\G::LoadTranslation("ID_RECORD_NOT_FOUND", array($sAssigneeUID))); } else { return $aUsers; } } catch (\Exception $e) { throw $e; } }
/** * task Case * * @param string sessionId : The session ID which is obtained when logging in * @param string caseId : The case ID. The caseList() function can be used to find the ID number for cases * @return $result returns the current task for a given case. Note that the logged-in user must have privileges * to access the task */ public function taskCase ($caseId) { $result = array (); try { $oCriteria = new Criteria( 'workflow' ); $del = DBAdapter::getStringDelimiter(); $oCriteria->addSelectColumn( AppDelegationPeer::DEL_INDEX ); $oCriteria->addSelectColumn( AppDelegationPeer::TAS_UID ); $oCriteria->addAsColumn( 'TAS_TITLE', 'C1.CON_VALUE' ); $oCriteria->addAlias( "C1", 'CONTENT' ); $tasTitleConds = array (); $tasTitleConds[] = array (AppDelegationPeer::TAS_UID,'C1.CON_ID'); $tasTitleConds[] = array ('C1.CON_CATEGORY',$del . 'TAS_TITLE' . $del); $tasTitleConds[] = array ('C1.CON_LANG',$del . SYS_LANG . $del); $oCriteria->addJoinMC( $tasTitleConds, Criteria::LEFT_JOIN ); $oCriteria->add( AppDelegationPeer::APP_UID, $caseId ); $oCriteria->add( AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN' ); $oCriteria->add( AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL ); $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $result[] = array ( 'guid' => $aRow['TAS_UID'], 'name' => $aRow['TAS_TITLE'], 'delegate' => $aRow['DEL_INDEX'] ); $oDataset->next(); } return $result; } catch (Exception $e) { $result[] = array ('guid' => $e->getMessage(),'name' => $e->getMessage(), 'delegate' => $e->getMessage() ); return $result; } }
public static function findByAmount($page, $size, $order = 'desc') { $sql = "(SELECT COUNT(%s) FROM %s INNER JOIN %s On %s=%s INNER JOIN %s ON %s=%s WHERE %s=%s GROUP BY %s)"; $sql = sprintf($sql, QueryPeer::STANDARD_DEVIATION, QueryPeer::TABLE_NAME, ReportQueryPeer::TABLE_NAME, QueryPeer::ID, ReportQueryPeer::QUERY_ID, QueryResultPeer::TABLE_NAME, ReportQueryPeer::QUERY_ID, QueryResultPeer::QUERY_ID, ReportQueryPeer::REPORT_ID, ReportPeer::ID, ReportPeer::ID); $c = new Criteria(); $c->addAsColumn('result_count', $sql); $c->add(ReportPeer::PUBLIC_RECORD, true); if ($order == 'asc') { $c->addAscendingOrderByColumn('result_count'); } else { $c->addDescendingOrderByColumn('result_count'); } $pager = new sfPropelPager('Report', $size); $pager->setCriteria($c); $pager->setPage($page); $pager->init(); return $pager; }
function getAllContentsByRole($sys_lang = SYS_LANG) { if (!isset($sys_lang)) { $sys_lang = 'en'; } $oCriteria = new Criteria('workflow'); $oCriteria->clearSelectColumns(); $oCriteria->addSelectColumn(ContentPeer::CON_ID); $oCriteria->addAsColumn('ROL_NAME', ContentPeer::CON_VALUE); //$oCriteria->addAsColumn('ROL_UID', ContentPeer::CON_ID); $oCriteria->add(ContentPeer::CON_CATEGORY, 'ROL_NAME'); $oCriteria->add(ContentPeer::CON_LANG, $sys_lang); $oDataset = ContentPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $aRoles = array(); while ($oDataset->next()) { $xRow = $oDataset->getRow(); $aRoles[$xRow['CON_ID']] = $xRow['ROL_NAME']; } return $aRoles; }
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; }
/** * Ensures uniqueness of select column names by turning them all into aliases * This is necessary for queries on more than one table when the tables share a column name * Moved from BasePeer to DBAdapter and turned from static to non static * * @see http://propel.phpdb.org/trac/ticket/795 * * @param Criteria $criteria * @return Criteria The input, with Select columns replaced by aliases */ public function turnSelectColumnsToAliases(Criteria $criteria) { $selectColumns = $criteria->getSelectColumns(); // clearSelectColumns also clears the aliases, so get them too $asColumns = $criteria->getAsColumns(); $criteria->clearSelectColumns(); $columnAliases = $asColumns; // add the select columns back foreach ($selectColumns as $clause) { // Generate a unique alias $baseAlias = preg_replace('/\\W/', '_', $clause); $alias = $baseAlias; // If it already exists, add a unique suffix $i = 0; while (isset($columnAliases[$alias])) { $i++; $alias = $baseAlias . '_' . $i; } // Add it as an alias $criteria->addAsColumn($alias, $clause); $columnAliases[$alias] = $clause; } // Add the aliases back, don't modify them foreach ($asColumns as $name => $clause) { $criteria->addAsColumn($name, $clause); } return $criteria; }
} $alfabeto = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "Y", "X", "Z"); //$alfabeto=array("S"); foreach ($alfabeto as $lettera) { $uri = "http://www.senato.it/leg/" . $argv[1] . "/BGT/Schede/Attsen/Sen" . strtolower($lettera) . ".html"; $html = file_get_html($uri); if ($html) { } $sens = $html->find('ul.composizione li a'); foreach ($sens as $sen) { echo $sen->plaintext; echo "\t"; $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(OppPoliticoPeer::ID); $c->addAsColumn('FULLNAME', 'CONCAT_WS(" ", ' . OppPoliticoPeer::COGNOME . ', ' . OppPoliticoPeer::NOME . ')'); $rs = OppPoliticoPeer::doSelectRS($c); $pol_id = 0; $k = 0; while ($rs->next()) { if ($rs->getString(2) == trim($sen->plaintext)) { $pol_id = $rs->getInt(1) . "\t"; $k++; } } if ($pol_id == 0) { $cognome = explode(" ", trim($sen->plaintext)); $c = new Criteria(); $c->add(OppPoliticoPeer::COGNOME, $cognome[0] . "%", Criteria::LIKE); $results = OppPoliticoPeer::doSelect($c); if (count($results) > 0) {