本文整理汇总了PHP中BatchJobPeer::doSelectStmt方法的典型用法代码示例。如果您正苦于以下问题:PHP BatchJobPeer::doSelectStmt方法的具体用法?PHP BatchJobPeer::doSelectStmt怎么用?PHP BatchJobPeer::doSelectStmt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BatchJobPeer
的用法示例。
在下文中一共展示了BatchJobPeer::doSelectStmt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reload
/**
* Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
*
* This will only work if the object has been saved and has a valid primary key set.
*
* @param boolean $deep (optional) Whether to also de-associated any related objects.
* @param PropelPDO $con (optional) The PropelPDO connection to use.
* @return void
* @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
*/
public function reload($deep = false, PropelPDO $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("Cannot reload a deleted object.");
}
if ($this->isNew()) {
throw new PropelException("Cannot reload an unsaved object.");
}
if ($con === null) {
$con = Propel::getConnection(BatchJobPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
// We don't need to alter the object instance pool; we're just modifying this instance
// already in the pool.
$stmt = BatchJobPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
$row = $stmt->fetch(PDO::FETCH_NUM);
$stmt->closeCursor();
if (!$row) {
throw new PropelException('Cannot find matching row in the database to reload object values.');
}
$this->hydrate($row, 0, true);
// rehydrate
if ($deep) {
// also de-associate any related objects?
}
// if (deep)
}
示例2: set_time_limit
<?php
set_time_limit(0);
ini_set("memory_limit", "700M");
error_reporting(E_ALL);
chdir(dirname(__FILE__));
define('ROOT_DIR', realpath(dirname(__FILE__) . '/../../'));
require_once ROOT_DIR . '/infra/bootstrap_base.php';
require_once ROOT_DIR . '/infra/KAutoloader.php';
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "vendor", "propel", "*"));
KAutoloader::setClassMapFilePath(kConf::get("cache_root_path") . '/scripts/' . basename(__FILE__) . '.cache');
KAutoloader::register();
KalturaLog::setLogger(new KalturaStdoutLogger());
$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();
$createdAt = time() - 60 * 60 * 24;
$jobType = 0;
$c = new Criteria();
// $c->add(BatchJobPeer::CREATED_AT, $createdAt, Criteria::GREATER_THAN);
$c->add(BatchJobPeer::JOB_TYPE, $jobType);
// $c->add(BatchJobPeer::STATUS, BatchJob::BATCHJOB_STATUS_PENDING);
$c->clearSelectColumns();
$c->addSelectColumn('MAX(' . BatchJobPeer::PRIORITY . ')');
$stmt = BatchJobPeer::doSelectStmt($c, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
$maxPriority = $stmt->fetchColumn();
var_dump($maxPriority);
示例3: doSelect
/**
* Method to do selects.
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param PropelPDO $con
* @return array Array of selected Objects
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, PropelPDO $con = null)
{
return BatchJobPeer::populateObjects(BatchJobPeer::doSelectStmt($criteria, $con));
}
示例4: doSelectJoinAll
/**
* Selects a collection of BatchJob objects pre-filled with all related objects.
*
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return array Array of BatchJob objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
// Set the correct dbName if it has not been overridden
if ($criteria->getDbName() == Propel::getDefaultDB()) {
$criteria->setDbName(self::DATABASE_NAME);
}
BatchJobPeer::addSelectColumns($criteria);
$startcol2 = BatchJobPeer::NUM_COLUMNS - BatchJobPeer::NUM_LAZY_LOAD_COLUMNS;
BatchJobLockPeer::addSelectColumns($criteria);
$startcol3 = $startcol2 + (BatchJobLockPeer::NUM_COLUMNS - BatchJobLockPeer::NUM_LAZY_LOAD_COLUMNS);
$criteria->addJoin(BatchJobPeer::BATCH_JOB_LOCK_ID, BatchJobLockPeer::ID, $join_behavior);
$stmt = BatchJobPeer::doSelectStmt($criteria, $con);
$results = array();
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key1 = BatchJobPeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj1 = BatchJobPeer::getInstanceFromPool($key1))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://propel.phpdb.org/trac/ticket/509
// $obj1->hydrate($row, 0, true); // rehydrate
} else {
$cls = BatchJobPeer::getOMClass(false);
$obj1 = new $cls();
$obj1->hydrate($row);
BatchJobPeer::addInstanceToPool($obj1, $key1);
}
// if obj1 already loaded
// Add objects for joined BatchJobLock rows
$key2 = BatchJobLockPeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
$obj2 = BatchJobLockPeer::getInstanceFromPool($key2);
if (!$obj2) {
$cls = BatchJobLockPeer::getOMClass(false);
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
BatchJobLockPeer::addInstanceToPool($obj2, $key2);
}
// if obj2 loaded
// Add the $obj1 (BatchJob) to the collection in $obj2 (BatchJobLock)
$obj2->addBatchJob($obj1);
}
// if joined row not null
$results[] = $obj1;
}
$stmt->closeCursor();
return $results;
}
示例5: getNextJobPriority
public static function getNextJobPriority($jobType)
{
//$priorities = array(1 => 33, 2 => 27, 3 => 20, 4 => 13, 5 => 7);
$priorities = kConf::get('priority_percent');
$createdAt = time() - kConf::get('priority_time_range');
// $createdAt = kConf::get('priority_time_range');
$c = new Criteria();
$c->add(BatchJobPeer::CREATED_AT, $createdAt, Criteria::GREATER_THAN);
$c->add(BatchJobPeer::JOB_TYPE, $jobType);
$c->add(BatchJobPeer::STATUS, BatchJob::BATCHJOB_STATUS_PENDING);
$c->clearSelectColumns();
$c->addSelectColumn('MAX(' . BatchJobPeer::PRIORITY . ')');
$stmt = BatchJobPeer::doSelectStmt($c, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
$maxPriority = $stmt->fetchColumn();
// gets the current queues
$c = new Criteria();
$c->add(BatchJobPeer::CREATED_AT, $createdAt, Criteria::GREATER_THAN);
$c->add(BatchJobPeer::JOB_TYPE, $jobType);
$c->add(BatchJobPeer::STATUS, BatchJob::BATCHJOB_STATUS_PENDING, Criteria::GREATER_THAN);
$c->addGroupByColumn(BatchJobPeer::PRIORITY);
// To prevent stress on the master DB - use the slave for checking the queue sizes
$queues = BatchJobPeer::doCountGroupBy($c, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
// copy the queues and calcs the total
$total = 0;
$queues_size = array();
foreach ($queues as $queue) {
$queues_size[$queue['PRIORITY']] = $queue[BatchJobPeer::COUNT];
$total += $queue[BatchJobPeer::COUNT];
}
// go over the priorities and see if its percent not used
foreach ($priorities as $priority => $top_percent) {
if ($priority > $maxPriority) {
continue;
}
if (!isset($queues_size[$priority])) {
return $priority;
}
$percent = $queues_size[$priority] / ($total / 100);
if ($percent < $top_percent) {
return $priority;
}
}
return 1;
}