本文整理汇总了PHP中BasePeer::doUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP BasePeer::doUpdate方法的具体用法?PHP BasePeer::doUpdate怎么用?PHP BasePeer::doUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BasePeer
的用法示例。
在下文中一共展示了BasePeer::doUpdate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doUpdateAllModerations
public static function doUpdateAllModerations($selectCriteria, $values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
return BasePeer::doUpdate($selectCriteria, $values, $con);
}
示例2: delete
public function delete(PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(sfGuardGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
if ($this->isDefaultGroup()) {
throw new sfException('Cannot remove default group (ID ' . $this->id . ')!');
return false;
}
/*
* get default group
*
*/
$default_group = sfGuardGroupPeer::getDefaultGroup();
//get default group
/*
* check if servers has this group
* If servers found remove reference to group to be deleted
*/
$con->beginTransaction();
try {
//select from...
$c1 = new Criteria();
$c1->add(EtvaServerPeer::SF_GUARD_GROUP_ID, $this->getId());
//update set
$c2 = new Criteria();
$c2->add(EtvaServerPeer::SF_GUARD_GROUP_ID, $default_group->getId());
BasePeer::doUpdate($c1, $c2, $con);
parent::delete($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
示例3: execute
protected function execute($arguments = array(), $options = array())
{
$context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', 'dev', true));
parent::execute($arguments, $options);
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$con = $databaseManager->getDatabase($options['connection'])->getConnection();
// add your code here
$this->log('[INFO] Checking VirtAgents state...' . "\n");
$offset = sfConfig::get('app_node_keepalive_update') + sfConfig::get('app_node_keepalive_update_offset');
$total_nodes = EtvaNodePeer::doCount(new Criteria());
if ($total_nodes > 0) {
$con->beginTransaction();
$affected = 0;
try {
$offset_date = date("c", time() - $offset);
/*
* get nodes that have last_keepalive field outdated
*/
$c1 = new Criteria();
$c1->add(EtvaNodePeer::LAST_KEEPALIVE, $offset_date, Criteria::LESS_THAN);
$c1->add(EtvaNodePeer::STATE, EtvaNode::NODE_ACTIVE);
// only active
//update statement
$c2 = new Criteria();
$c2->add(EtvaNodePeer::STATE, EtvaNode::NODE_INACTIVE);
$affected += BasePeer::doUpdate($c1, $c2, $con);
// update maintenance and running to maintenance
$c1 = new Criteria();
$c1->add(EtvaNodePeer::LAST_KEEPALIVE, $offset_date, Criteria::LESS_THAN);
$c1->add(EtvaNodePeer::STATE, EtvaNode::NODE_MAINTENANCE_UP);
//update statement
$c2 = new Criteria();
$c2->add(EtvaNodePeer::STATE, EtvaNode::NODE_MAINTENANCE);
$affected += BasePeer::doUpdate($c1, $c2, $con);
// update fail and running to fail
$c1 = new Criteria();
$c1->add(EtvaNodePeer::LAST_KEEPALIVE, $offset_date, Criteria::LESS_THAN);
$c1->add(EtvaNodePeer::STATE, EtvaNode::NODE_FAIL_UP);
// only active
//update statement
$c2 = new Criteria();
$c2->add(EtvaNodePeer::STATE, EtvaNode::NODE_FAIL);
$affected += BasePeer::doUpdate($c1, $c2, $con);
$con->commit();
$message = sprintf('%d Node(s) NOT received update in time offset of %d seconds', $affected, $offset);
if ($affected > 0) {
$context->getEventDispatcher()->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
}
$this->log('[INFO]' . $message);
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
$logger = new sfFileLogger($context->getEventDispatcher(), array('file' => sfConfig::get("sf_log_dir") . '/cron_status.log'));
// log the message!
$logger->log("[INFO] The check virtAgents task ran!", 6);
}
示例4: testDoUpdate
public function testDoUpdate()
{
try {
$c1 = new Criteria();
$c1->setPrimaryTableName(BookPeer::TABLE_NAME);
$c1->add(BookPeer::ID, 12, ' BAD SQL');
$c2 = new Criteria();
$c2->add(BookPeer::TITLE, 'Foo');
BasePeer::doUpdate($c1, $c2, Propel::getConnection());
} catch (PropelException $e) {
$this->assertContains('[UPDATE `book` SET `TITLE`=:p1 WHERE book.ID BAD SQL:p2]', $e->getMessage(), 'SQL query is written in the exception message');
}
}
示例5: entryDeleted
/**
* @param int $entryId
*/
protected function entryDeleted($entryId)
{
$c = new Criteria();
$c->add(CuePointPeer::ENTRY_ID, $entryId);
CuePointPeer::setUseCriteriaFilter(false);
$cuePoints = CuePointPeer::doSelect($c);
$update = new Criteria();
$update->add(CuePointPeer::STATUS, CuePointStatus::DELETED);
$con = Propel::getConnection(myDbHelper::DB_HELPER_CONN_MASTER);
BasePeer::doUpdate($c, $update, $con);
foreach ($cuePoints as $cuePoint) {
kEventsManager::raiseEvent(new kObjectDeletedEvent($cuePoint));
}
}
示例6: entryDeleted
/**
* @param int $entryId
*/
protected function entryDeleted($entryId)
{
$c = new Criteria();
$c->add(AnnotationPeer::ENTRY_ID, $entryId);
$c->add(AnnotationPeer::STATUS, AnnotationStatus::ANNOTATION_STATUS_DELETED, Criteria::NOT_EQUAL);
AnnotationPeer::setUseCriteriaFilter(false);
$annotations = AnnotationPeer::doSelect($c);
foreach ($annotations as $annotation) {
kEventsManager::raiseEvent(new kObjectDeletedEvent($annotation));
}
$update = new Criteria();
$update->add(AnnotationPeer::STATUS, AnnotationStatus::ANNOTATION_STATUS_DELETED);
$con = Propel::getConnection(AnnotationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
BasePeer::doUpdate($c, $update, $con);
}
示例7: deleteMetadataObjects
/**
* @param int $objectType
* @param string $objectId
*/
protected function deleteMetadataObjects($objectType, $objectId)
{
$c = new Criteria();
$c->add(MetadataPeer::OBJECT_TYPE, $objectType);
$c->add(MetadataPeer::OBJECT_ID, $objectId);
$c->add(MetadataPeer::STATUS, Metadata::STATUS_DELETED, Criteria::NOT_EQUAL);
$peer = null;
MetadataPeer::setUseCriteriaFilter(false);
$metadatas = MetadataPeer::doSelect($c);
foreach ($metadatas as $metadata) {
kEventsManager::raiseEvent(new kObjectDeletedEvent($metadata));
}
$update = new Criteria();
$update->add(MetadataPeer::STATUS, Metadata::STATUS_DELETED);
$con = Propel::getConnection(MetadataPeer::DATABASE_NAME, Propel::CONNECTION_READ);
BasePeer::doUpdate($c, $update, $con);
}
示例8: setJobStateIds
public static function setJobStateIds($jobs, $stateId)
{
$c1 = new Criteria();
$c2 = new Criteria();
$c1->add(JobPeer::ID, $jobs, Criteria::IN);
$c2->add(JobPeer::STATUS_ID, $stateId);
BasePeer::doUpdate($c1, $c2, Propel::getConnection());
$state = StatusPeer::retrieveByPK($stateId);
foreach ($jobs as $id) {
$logEntry = new Log();
$logEntry->setWhen(time());
$logEntry->setPropelClass("Job");
$logEntry->setSfGuardUserProfileId(sfContext::getInstance()->getUser()->getUserId());
$logEntry->setMessage("Changed job state to " . $state->getState());
$logEntry->setLogMessageTypeId(sfConfig::get("app_log_type_change_status"));
$logEntry->setPropelId($id);
$logEntry->save();
}
}
示例9: lockObjects
private static function lockObjects(kExclusiveLockKey $lockKey, array $objects, $max_execution_time)
{
$exclusive_objects = array();
// make sure the objects where not taken -
$con = Propel::getConnection();
$not_exclusive_count = 0;
foreach ($objects as $object) {
$lock_version = $object->getLockVersion();
$criteria_for_exclusive_update = new Criteria();
$criteria_for_exclusive_update->add(BatchJobPeer::ID, $object->getId());
$criteria_for_exclusive_update->add(BatchJobPeer::LOCK_VERSION, $lock_version);
$update = new Criteria();
// increment the lock_version - this will make sure it's exclusive
$update->add(BatchJobPeer::LOCK_VERSION, $lock_version + 1);
// increment the execution_attempts
$update->add(BatchJobPeer::EXECUTION_ATTEMPTS, $object->getExecutionAttempts() + 1);
$update->add(BatchJobPeer::SCHEDULER_ID, $lockKey->getSchedulerId());
$update->add(BatchJobPeer::WORKER_ID, $lockKey->getWorkerId());
$update->add(BatchJobPeer::BATCH_INDEX, $lockKey->getBatchIndex());
$update->add(BatchJobPeer::LAST_SCHEDULER_ID, $lockKey->getSchedulerId());
$update->add(BatchJobPeer::LAST_WORKER_ID, $lockKey->getWorkerId());
$processor_expiration = time() + $max_execution_time;
$update->add(BatchJobPeer::PROCESSOR_EXPIRATION, $processor_expiration);
$affectedRows = BasePeer::doUpdate($criteria_for_exclusive_update, $update, $con);
KalturaLog::log("Lock update affected rows [{$affectedRows}] on job id [" . $object->getId() . "] lock version [{$lock_version}]");
if ($affectedRows == 1) {
// fix the object to reflect what is in the DB
$object->setLockVersion($lock_version + 1);
$object->setExecutionAttempts($object->getExecutionAttempts() + 1);
$object->setSchedulerId($lockKey->getSchedulerId());
$object->setWorkerId($lockKey->getWorkerId());
$object->setBatchIndex($lockKey->getBatchIndex());
$object->setProcessorExpiration($processor_expiration);
KalturaLog::log("Job id [" . $object->getId() . "] locked and returned");
$exclusive_objects[] = $object;
} else {
$not_exclusive_count++;
KalturaLog::log("Object not exclusive: [" . get_class($object) . "] id [" . $object->getId() . "]");
}
}
return $exclusive_objects;
}
示例10: executeImpl
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
{
$job_type = $this->getPM("job_type");
$processor_name = $this->getPM("processor_name");
$processor_timeout = $this->getPM("processor_timeout");
$over_quota_partners = $this->getPM("over_quota_partners");
$defered_partners = $this->getPM("defered_partners");
$con = Propel::getConnection();
// fetch one pending row of a given job_type
// where the over_quota_partner requests are dropped
// and defered_partners request are of less priority
$query = "SELECT " . BatchJobPeer::ID . " FROM " . BatchJobPeer::TABLE_NAME . " WHERE " . BatchJobPeer::STATUS . "=" . BatchJob::BATCHJOB_STATUS_PENDING . " AND " . BatchJobPeer::JOB_TYPE . "=" . $job_type . " " . (count($over_quota_partners) ? " AND " . BatchJobPeer::PARTNER_ID . " NOT IN ({$over_quota_partners}) " : "") . " ORDER BY " . (count($defered_partners) ? BatchJobPeer::PARTNER_ID . " IN ({$defered_partners}), " : "") . BatchJobPeer::CREATED_AT . " LIMIT 1";
$statement = $con->prepareStatement($query);
$resultset = $statement->executeQuery();
$batch_job = null;
while ($resultset->next()) {
$batch_job = BatchJobPeer::retrieveByPK($resultset->getInt('ID'));
}
$batch_job = BatchJobPeer::doSelectOne($c);
if ($batch_job) {
// force update to work on the currently selected row and ensure it is still in pending status
$c->add(BatchJobPeer::ID, $batch_job->getId());
$c->add(BatchJobPeer::STATUS, BatchJob::BATCHJOB_STATUS_PENDING);
$update = new Criteria();
$update->add(BatchJobPeer::STATUS, BatchJob::BATCHJOB_STATUS_QUEUED);
$update->add(BatchJobPeer::PROCESSOR_NAME, $processor_name);
$update->add(BatchJobPeer::PROCESSOR_EXPIRATION, time() + $processor_timeout);
$affectedRows = BasePeer::doUpdate($c, $update, $con);
if ($affectedRows != 1) {
$batch_job = null;
}
}
if (!$batch_job) {
//xx$this->addError ( APIErrors::INVALID_ENTRY_ID, $this->getObjectPrefix() , $entry_id );
} else {
$wrapper = objectWrapperBase::getWrapperClass($batch_job, objectWrapperBase::DETAIL_LEVEL_REGULAR);
// TODO - remove this code when cache works properly when saving objects (in their save method)
$wrapper->removeFromCache("batch_job", $batch_job->getId());
$this->addMsg("batchjob", $wrapper);
}
}
示例11: lockJob
function lockJob($object)
{
global $jobStatus;
$con = Propel::getConnection();
$lock_version = $object->getVersion();
$criteria_for_exclusive_update = new Criteria();
$criteria_for_exclusive_update->add(BatchJobLockPeer::ID, $object->getId());
$criteria_for_exclusive_update->add(BatchJobLockPeer::VERSION, $lock_version);
$criteria_for_exclusive_update->add(BatchJobLockPeer::STATUS, $jobStatus);
$update = new Criteria();
// increment the lock_version - this will make sure it's exclusive
$update->add(BatchJobLockPeer::VERSION, $lock_version + 1);
$update->add(BatchJobLockPeer::STATUS, TEMP_JOB_STATUS);
$affectedRows = BasePeer::doUpdate($criteria_for_exclusive_update, $update, $con);
if ($affectedRows != 1) {
return false;
}
// update $object with what is in the database
$object->setVersion($lock_version + 1);
$object->setStatus(TEMP_JOB_STATUS);
return true;
}
示例12: setDefaultGroup
public function setDefaultGroup()
{
$con = Propel::getConnection(sfGuardGroupPeer::DATABASE_NAME);
$criteria = new Criteria();
$criteria->add(self::NAME, 'Admin');
$group = self::doSelectOne($criteria);
$new = false;
if (!$group) {
$group = new sfGuardGroup();
$new = true;
}
$group->setName('Admin');
$group->setDescription('Admin Group');
if ($new) {
$group->save();
}
$selectCriteria = $group->buildPkeyCriteria();
// update values are also stored in Criteria object
$group->setId(self::DEFAULT_GROUP_ID);
$updateValues = $group->buildCriteria();
BasePeer::doUpdate($selectCriteria, $updateValues, $con);
return $group;
}
示例13: saveVNCkeymap
public function saveVNCkeymap(PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(EtvaSettingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$con->beginTransaction();
$isInsert = $this->isNew();
try {
parent::save($con);
//select statement
$c1 = new Criteria();
$c1->add(EtvaServerPeer::VNC_KEYMAP_DEFAULT, 1, Criteria::EQUAL);
//update statement
$c2 = new Criteria();
$c2->add(EtvaServerPeer::VNC_KEYMAP, $this->getValue());
BasePeer::doUpdate($c1, $c2, $con);
$con->commit();
return true;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
示例14: doSoftDeleteAll
/**
* Method to soft delete all rows from the a_traitements table.
*
* @param PropelPDO $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSoftDeleteAll(PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(AbsenceEleveTraitementPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$selectCriteria = new Criteria();
$selectCriteria->add(AbsenceEleveTraitementPeer::DELETED_AT, null, Criteria::ISNULL);
$selectCriteria->setDbName(AbsenceEleveTraitementPeer::DATABASE_NAME);
$modifyCriteria = new Criteria();
$modifyCriteria->add(AbsenceEleveTraitementPeer::DELETED_AT, time());
return BasePeer::doUpdate($selectCriteria, $modifyCriteria, $con);
}
示例15: doUpdate
public static function doUpdate($values, $con = null)
{
foreach (sfMixer::getCallables('BasenahoWikiPagePeer:doUpdate:pre') as $callable) {
$ret = call_user_func($callable, 'BasenahoWikiPagePeer', $values, $con);
if (false !== $ret) {
return $ret;
}
}
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values;
$comparison = $criteria->getComparison(nahoWikiPagePeer::ID);
$selectCriteria->add(nahoWikiPagePeer::ID, $criteria->remove(nahoWikiPagePeer::ID), $comparison);
} else {
$criteria = $values->buildCriteria();
$selectCriteria = $values->buildPkeyCriteria();
}
$criteria->setDbName(self::DATABASE_NAME);
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
foreach (sfMixer::getCallables('BasenahoWikiPagePeer:doUpdate:post') as $callable) {
call_user_func($callable, 'BasenahoWikiPagePeer', $values, $con, $ret);
}
return $ret;
}