本文整理汇总了PHP中myDbHelper::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP myDbHelper::getConnection方法的具体用法?PHP myDbHelper::getConnection怎么用?PHP myDbHelper::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myDbHelper
的用法示例。
在下文中一共展示了myDbHelper::getConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeSolrLog
public function writeSolrLog($entry)
{
KalturaLog::debug("writeSolrLog " . $entry->getId());
$solrLog = new SphinxLog();
$solrLog->setEntryId($entry->getId());
$solrLog->setPartnerId($entry->getPartnerId());
$solrLog->save(myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_SOLR_LOG));
}
示例2: alternativeCon
public static function alternativeCon($con, $queryDB = kQueryCache::QUERY_DB_UNDEFINED)
{
if ($con === null) {
$con = myDbHelper::alternativeCon($con);
}
if ($con === null) {
$con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL3);
}
return $con;
}
示例3: alternativeCon
public static function alternativeCon($con)
{
if ($con === null) {
$con = myDbHelper::alternativeCon($con);
}
if ($con === null) {
$con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL3);
}
return $con;
}
示例4: getConfigs
public function getConfigs()
{
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn('MAX(' . SchedulerConfigPeer::ID . ')');
$c->addGroupByColumn(SchedulerConfigPeer::VARIABLE);
$c->addGroupByColumn(SchedulerConfigPeer::VARIABLE_PART);
$c->addAscendingOrderByColumn(SchedulerConfigPeer::VARIABLE);
$c->add(SchedulerConfigPeer::SCHEDULER_ID, $this->id);
$c->add(SchedulerConfigPeer::WORKER_ID, null);
$rs = SchedulerConfigPeer::doSelectStmt($c, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
$configIds = $rs->fetchAll(PDO::FETCH_COLUMN, 0);
return SchedulerConfigPeer::retrieveByPKs($configIds, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
}
示例5: doQueueStatus
public static function doQueueStatus(PDO $con = null)
{
if (is_null($con)) {
$con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2);
}
// $con = Propel::getConnection(BatchJobPeer::DATABASE_NAME);
$stmt = null;
try {
$now = time();
$sql = "SELECT\t\tAVG(TIMEDIFF(NOW(), CREATED_AT)) AS CREATED_AT_AVG,\n\t\t\t\t\t\t\t\tCOUNT(JOB_TYPE) AS JOB_TYPE_COUNT, \n\t\t\t\t\t\t\t\tJOB_TYPE \n\t\t\t\t\tFROM\t\tbatch_job \n\t\t\t\t\tFORCE INDEX (created_at_job_type_status_index)\n\t\t\t\t\tWHERE\t\tSTATUS IN (" . BatchJob::BATCHJOB_STATUS_PENDING . ',' . BatchJob::BATCHJOB_STATUS_RETRY . ")\n\t\t\t\t\tAND\t\t\t(\n\t\t\t\t\t\t\t\t\tCHECK_AGAIN_TIMEOUT < {$now}\n\t\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\tCHECK_AGAIN_TIMEOUT IS NULL\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\tAND\t\t\tJOB_TYPE IS NOT NULL\n\t\t\t\t\tAND\t\t\tCREATED_AT > DATE_ADD(NOW(), INTERVAL -1 HOUR)\n\t\t\t\t\tGROUP BY\tJOB_TYPE";
$stmt = $con->query($sql);
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException($e);
}
return $stmt->fetchAll();
}
示例6: 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);
示例7: basename
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "vendor", "propel", "*"));
KAutoloader::setClassMapFilePath(kConf::get("cache_root_path") . '/scripts/' . basename(__FILE__) . '.cache');
KAutoloader::register();
date_default_timezone_set(kConf::get("date_default_timezone"));
$loggerConfigPath = ROOT_DIR . '/scripts/logger.ini';
$config = new Zend_Config_Ini($loggerConfigPath);
KalturaLog::initLog($config);
KalturaLog::setContext(basename(__FILE__));
KalturaLog::info("Starting script");
KalturaLog::info("Initializing database...");
DbManager::setConfig(kConf::getDB());
DbManager::initialize();
KalturaLog::info("Database initialized successfully");
$syncType = 'kuser';
$dbh = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_DWH);
$sql = "CALL get_data_for_operational('{$syncType}')";
$count = 0;
$rows = $dbh->query($sql)->fetchAll();
foreach ($rows as $row) {
$kuser = kuserPeer::retrieveByPK($row['kuser_id']);
if (is_null($kuser)) {
KalturaLog::err('Couldn\'t find kuser [' . $row['kuser_id'] . ']');
continue;
}
$kuser->setStorageSize($row['storage_size']);
$kuser->save();
$count++;
KalturaLog::debug('Successfully saved kuser [' . $row['kuser_id'] . ']');
if ($count % 500) {
kuserPeer::clearInstancePool();
示例8: while
$lastFileSyncId = null;
$loopLimit = 500;
while ($moreFileSyncs) {
// ----------------------------
// get next remote file syncs
// ----------------------------
$exportedFileSyncsCriteria = new Criteria();
$exportedFileSyncsCriteria->setLimit($loopLimit);
$exportedFileSyncsCriteria->addAscendingOrderByColumn(FileSyncPeer::ID);
$exportedFileSyncsCriteria->addAnd(FileSyncPeer::DC, $storageProfileId, Criteria::EQUAL);
$exportedFileSyncsCriteria->addAnd(FileSyncPeer::STATUS, FileSync::FILE_SYNC_STATUS_READY, Criteria::EQUAL);
$exportedFileSyncsCriteria->addAnd(FileSyncPeer::PARTNER_ID, $partnerId, Criteria::EQUAL);
if ($lastFileSyncId) {
$exportedFileSyncsCriteria->addAnd(FileSyncPeer::ID, $lastFileSyncId, Criteria::GREATER_THAN);
}
$exportedFileSyncs = FileSyncPeer::doSelect($exportedFileSyncsCriteria, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL3));
// -----------------------------------------------
// delete the local dcs copies of each file sync
// -----------------------------------------------
foreach ($exportedFileSyncs as $exportedFileSync) {
$lastFileSyncId = $exportedFileSync->getId();
$syncKey = kFileSyncUtils::getKeyForFileSync($exportedFileSync);
echo 'Deleting file sync key - ' . serialize($syncKey) . PHP_EOL;
kFileSyncUtils::deleteSyncFileForKey($syncKey, false, true);
// 3rd param = true -> only delete from local dcs
}
// --------------------------
// check if loop should end
// --------------------------
if (count($exportedFileSyncs) < $loopLimit) {
$moreFileSyncs = false;
示例9: SphinxLog
if (is_null($entry)) {
KalturaLog::err('Couldn\'t find entry [' . $entryId . ']');
continue;
}
if ($entry->getViews() != $views || $entry->getPlays() != $plays) {
$entry->setViews($views);
$entry->setPlays($plays);
KalturaLog::debug('Successfully saved entry [' . $entryId . ']');
try {
// update entry without setting the updated at
$updateSql = "UPDATE entry set views='{$views}',plays='{$plays}' WHERE id='{$entryId}'";
$stmt = $connection->prepare($updateSql);
$stmt->execute();
$affectedRows = $stmt->rowCount();
KalturaLog::log("AffectedRows: " . $affectedRows);
// update sphinx log directly
$sql = $sphinxMgr->getSphinxSaveSql($entry, false);
$sphinxLog = new SphinxLog();
$sphinxLog->setEntryId($entryId);
$sphinxLog->setPartnerId($entry->getPartnerId());
$sphinxLog->setSql($sql);
$sphinxLog->save(myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_SPHINX_LOG));
} catch (Exception $e) {
KalturaLog::log($e->getMessage(), Propel::LOG_ERR);
}
}
$count++;
if ($count % 500 === 0) {
entryPeer::clearInstancePool();
}
}
示例10: alternativeCon
public static function alternativeCon($con, $queryDB = kQueryCache::QUERY_DB_UNDEFINED)
{
return myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_SPHINX_LOG);
}
示例11: getExpiredJobs
public static function getExpiredJobs()
{
$jobTypes = kPluginableEnumsManager::coreValues('BatchJobType');
$executionAttempts2jobTypes = array();
// Map between max execution attempts and job types
foreach ($jobTypes as $jobType) {
$executionAttempts = BatchJobLockPeer::getMaxExecutionAttempts($jobType);
if (array_key_exists($executionAttempts, $executionAttempts2jobTypes)) {
$executionAttempts2jobTypes[$executionAttempts][] = $jobType;
} else {
$executionAttempts2jobTypes[$executionAttempts] = array($jobType);
}
}
// create query
$c = new Criteria();
$c->add(BatchJobLockPeer::STATUS, BatchJob::BATCHJOB_STATUS_FATAL, Criteria::NOT_EQUAL);
$c->add(BatchJobLockPeer::DC, kDataCenterMgr::getCurrentDcId());
// each DC should clean its own jobs
// Query for each job type
$batchJobLocks = array();
foreach ($executionAttempts2jobTypes as $execAttempts => $jobTypes) {
$typedCrit = clone $c;
$typedCrit->add(BatchJobLockPeer::EXECUTION_ATTEMPTS, $execAttempts, Criteria::GREATER_THAN);
$typedCrit->add(BatchJobLockPeer::JOB_TYPE, $jobTypes, Criteria::IN);
$typedJobs = BatchJobLockPeer::doSelect($typedCrit, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
foreach ($typedJobs as $typedJob) {
$batchJobLocks[$typedJob->getId()] = $typedJob;
}
}
// get matching batch jobs
return BatchJobPeer::retrieveByPKs(array_keys($batchJobLocks));
}
示例12: while
} else {
$c->add(BatchJobLockPeer::PARTNER_ID, $partnerId);
}
}
$c->setLimit(CHUNK_SIZE);
$movedJobsCount = 0;
while ($movedJobsCount < $maxMovedJobs) {
$jobLocks = BatchJobLockPeer::doSelect($c, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
if (!$jobLocks) {
break;
}
$initialMovedJobsCount = $movedJobsCount;
foreach ($jobLocks as $jobLock) {
/* @var $jobLock BatchJobLock */
/* @var $job BatchJob */
$job = $jobLock->getBatchJob(myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
// check whether the job can be moved
$jobData = $job->getData();
/* @var $jobData kConvartableJobData */
$srcFileSyncs = $jobData->getSrcFileSyncs();
if (count($srcFileSyncs) != 1) {
continue;
}
// unexpected - multiple sources for doc convert
$srcFileSync = reset($srcFileSyncs);
/* @var $srcFileSync kSourceFileSyncDescriptor */
$sourceAsset = assetPeer::retrieveById($srcFileSync->getAssetId());
if (!$sourceAsset) {
continue;
}
// unexpected - source flavor asset not found
示例13: alternativeCon
public static function alternativeCon($con)
{
return myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_SPHINX_LOG);
}
示例14: getExpiredJobs
public static function getExpiredJobs()
{
$jobTypes = kPluginableEnumsManager::coreValues('BatchJobType');
$c = new Criteria();
$c->add(BatchJobPeer::STATUS, BatchJob::BATCHJOB_STATUS_FATAL, Criteria::NOT_EQUAL);
$c->add(BatchJobPeer::DC, kDataCenterMgr::getCurrentDcId());
// each DC should clean its own jobs
// $c->add(BatchJobPeer::PROCESSOR_EXPIRATION, time(), Criteria::LESS_THAN);
// $c->add(BatchJobPeer::SCHEDULER_ID, 0, Criteria::GREATER_THAN);
// $c->add(BatchJobPeer::WORKER_ID, 0, Criteria::GREATER_THAN);
$jobs = array();
foreach ($jobTypes as $jobType) {
$typedCrit = clone $c;
$typedCrit->add(BatchJobPeer::EXECUTION_ATTEMPTS, BatchJobPeer::getMaxExecutionAttempts($jobType), Criteria::GREATER_THAN);
$typedCrit->add(BatchJobPeer::JOB_TYPE, $jobType);
$typedJobs = BatchJobPeer::doSelect($typedCrit, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
foreach ($typedJobs as $typedJob) {
$jobs[] = $typedJob;
}
}
return $jobs;
}
示例15: updateAction
/**
* Update Conversion Profile by ID
*
* @action update
* @param int $id
* @param KalturaConversionProfile $conversionProfile
* @return KalturaConversionProfile
*/
public function updateAction($id, KalturaConversionProfile $conversionProfile)
{
if ($conversionProfile->name !== null) {
$conversionProfile->validatePropertyMinLength("name", 1);
}
if ($conversionProfile->flavorParamsIds !== null) {
$conversionProfile->validateFlavorParamsIds();
}
$conversionProfileDb = conversionProfile2Peer::retrieveByPK($id);
if (!$conversionProfileDb) {
throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $id);
}
$conversionProfile->toUpdatableObject($conversionProfileDb);
$conversionProfileDb->setCreationMode(conversionProfile2::CONVERSION_PROFILE_2_CREATION_MODE_KMC);
$conversionProfileDb->save();
if ($conversionProfile->flavorParamsIds !== null) {
$this->deleteFlavorParamsRelation($conversionProfileDb);
$this->addFlavorParamsRelation($conversionProfileDb, $conversionProfile->getFlavorParamsAsArray());
}
$conversionProfile->fromObject($conversionProfileDb);
// load flavor params id with the same connection (master connection) that was used for insert
$con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_MASTER);
$conversionProfile->loadFlavorParamsIds($conversionProfileDb, $con);
return $conversionProfile;
}