本文整理汇总了PHP中Propel::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Propel::close方法的具体用法?PHP Propel::close怎么用?PHP Propel::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel
的用法示例。
在下文中一共展示了Propel::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dup
public static function dup($class_name, $old_id, $new_id)
{
$obj = self::select($class_name, "id={$old_id}");
if (!$obj) {
throw new Exception(__CLASS__ . ": error! did not find [{$class_name}] with {$old_id} to duplicate");
}
$temp_obj = self::select($class_name, "id={$new_id}");
if ($temp_obj) {
throw new Exception(__CLASS__ . ": error! [{$class_name}] with {$new_id} already exists in db. cannot duplicate");
}
$new_obj = $obj->copy();
$new_obj->save();
$stored_id = $new_obj->getId();
// echo "stored_id: $stored_id\n";
$db_connection = Propel::getConnection();
$db_connection->begin();
$db_connection->executeUpdate("UPDATE {$class_name} set id={$new_id} WHERE id={$stored_id};");
$db_connection->commit();
//$db_connection->close();
Propel::close();
}
示例2: execute
//.........这里部分代码省略.........
}
$flavorAsset = flavorAssetPeer::retrieveById($flavorId);
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$entry = entryPeer::retrieveByPK($flavorAsset->getEntryId());
if (is_null($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
myPartnerUtils::blockInactivePartner($flavorAsset->getPartnerId());
myPartnerUtils::enforceDelivery($flavorAsset->getPartnerId());
//disabled enforce cdn because of rtmp delivery
//requestUtils::enforceCdnDelivery($flavorAsset->getPartnerId());
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (!kFileSyncUtils::file_exists($syncKey, false)) {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
// always dump remote urls so they will be cached by the cdn transparently
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
kFile::dumpUrl($remoteUrl, true, true);
}
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
$flvWrapper = new myFlvHandler($path);
$isFlv = $flvWrapper->isFlv();
$clipFrom = $this->getRequestParameter("clipFrom", 0);
// milliseconds
$clipTo = $this->getRequestParameter("clipTo", 2147483647);
// milliseconds
if ($clipTo == 0) {
$clipTo = 2147483647;
}
if (is_dir($path) && $fileParam) {
$path .= "/{$fileParam}";
//echo "path($path),file($fileParam)";
kFile::dumpFile($path, null, null);
die;
} else {
if (!$isFlv) {
$limit_file_size = 0;
if ($clipTo != 2147483647) {
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAsset->getId());
if ($mediaInfo && ($mediaInfo->getVideoDuration() || $mediaInfo->getAudioDuration() || $mediaInfo->getContainerDuration())) {
$duration = $mediaInfo->getVideoDuration() ? $mediaInfo->getVideoDuration() : ($mediaInfo->getAudioDuration() ? $mediaInfo->getAudioDuration() : $mediaInfo->getContainerDuration());
$limit_file_size = floor(@filesize($path) * ($clipTo / $duration));
}
}
kFile::dumpFile($path, null, null, $limit_file_size);
die;
}
}
$audioOnly = $this->getRequestParameter("audioOnly");
// milliseconds
if ($audioOnly === '0') {
// audioOnly was explicitly set to 0 - don't attempt to make further automatic investigations
} elseif ($flvWrapper->getFirstVideoTimestamp() < 0) {
$audioOnly = true;
}
$seekFrom = $this->getRequestParameter("seekFrom", -1);
if ($seekFrom <= 0) {
$seekFrom = -1;
}
$seekFromBytes = $this->getRequestParameter("seekFromBytes", -1);
if ($seekFromBytes <= 0) {
$seekFromBytes = -1;
}
$bytes = 0;
if ($seekFrom !== -1 && $seekFrom !== 0) {
list($bytes, $duration, $firstTagByte, $toByte) = $flvWrapper->clip(0, -1, $audioOnly);
list($bytes, $duration, $fromByte, $toByte, $seekFromTimestamp) = $flvWrapper->clip($seekFrom, -1, $audioOnly);
$seekFromBytes = myFlvHandler::FLV_HEADER_SIZE + $flvWrapper->getMetadataSize($audioOnly) + $fromByte - $firstTagByte;
} else {
list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
}
$metadataSize = $flvWrapper->getMetadataSize($audioOnly);
$dataOffset = $metadataSize + myFlvHandler::getHeaderSize();
$totalLength = $dataOffset + $bytes;
list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
list($rangeFrom, $rangeTo, $rangeLength) = requestUtils::handleRangeRequest($totalLength);
if ($totalLength < 1000) {
// (actually $total_length is probably 13 or 143 - header + empty metadata tag) probably a bad flv maybe only the header - dont cache
requestUtils::sendCdnHeaders("flv", $rangeLength, 0);
} else {
requestUtils::sendCdnHeaders("flv", $rangeLength);
}
header('Content-Disposition: attachment; filename="video.flv"');
// dont inject cuepoint into the stream
$cuepointTime = 0;
$cuepointPos = 0;
try {
Propel::close();
} catch (Exception $e) {
$this->logMessage("serveFlavor: error closing db {$e}");
}
header("Content-Type: video/x-flv");
$flvWrapper->dump(self::CHUNK_SIZE, $fromByte, $toByte, $audioOnly, $seekFromBytes, $rangeFrom, $rangeTo, $cuepointTime, $cuepointPos);
die;
}
示例3: closePropel
/**
* Close the propel connection from initPropel
*/
private function closePropel()
{
Propel::close();
$this->initPropel = false;
$this->initPropelRoot = false;
}
示例4: executeAccept_group
public function executeAccept_group(sfWebRequest $request)
{
$invitacion_id = $request->getParameter('invitacion');
$token_seguridad = $request->getParameter('token');
$email_token = $request->getParameter('email');
$user_token = $request->getParameter('account');
/*vamos a aceptar permanecer a un grupo
aca realizo validacion en 5 capas
1 reviso que la session de usuario exista
2 que la el valor obtenido en la consulta sea un object(que la consulta sql resulte con el registro solicitado)
3 el token de la solicitud sea correcto
4 el email sea correcto
5 que el usuario id sea correcto (este es id del usuario que envio la solicitud en md5)
*/
$user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
if ($user != null) {
$solicitud = SolicitudGrupoTrabajoScPeer::retrieveByPK($invitacion_id);
if (is_object($solicitud)) {
if ($token_seguridad == $solicitud->getToken()) {
if ($email_token == md5($user->getEmail())) {
if ($user_token == md5($solicitud->getUserId())) {
$solicitud->setRespondido(1);
$solicitud->setFlag(json_encode(array("estado" => false, "respuesta" => true)));
$solicitud->setUpdateAt(time());
$solicitud->save();
//falta cambiar los indicadores que esten relacionados al grupo
/*vamos a obtener todos los arboles que esten relacionados con el grupo
depues vamos a obtener todos los indicadores donde el usuario se encuentre
asignado y vamos a aumetar el ID en cada registro que encontremos*/
//admemas vamos hacer lo mismo en las asignaciones para tener un mejor indexacion
//a la hora de hacer las consultas.
$criterio_tree = new Criteria();
$criterio_tree->add(TreeScPeer::GRUPO_TRABAJO_ID, $solicitud->getGrupoId());
$list_tree = TreeScPeer::doSelect($criterio_tree);
foreach ($list_tree as $row) {
$con = Propel::getConnection();
$criterio_busqueda = new Criteria();
$criterio_busqueda->add(IndicatorsScPeer::EMAIL_RESPONSABLE, '%' . $solicitud->getEmail() . '%', Criteria::LIKE);
$criterio_busqueda->add(IndicatorsScPeer::TREE_ID, $row->getId());
$criterio_update = new Criteria();
$criterio_update->add(IndicatorsScPeer::RESPONSABLE_ID, $user->getId());
BasePeer::doUpdate($criterio_busqueda, $criterio_update, $con);
$con = Propel::close();
}
$con = Propel::getConnection();
$criterio_asignaciones = new Criteria();
$criterio_asignaciones->add(AsignacionScPeer::GRUPO_ID, $solicitud->getGrupoId());
$criterio_asignaciones->add(AsignacionScPeer::EMAIL, '%' . $user->getEmail() . '%', Criteria::LIKE);
$criterio_update = new Criteria();
$criterio_update->add(AsignacionScPeer::USER_ID, $user->getId());
BasePeer::doUpdate($criterio_asignaciones, $criterio_update, $con);
$con = Propel::close();
$grupo_trabajo = new DetalleGrupoTrabajoSc();
$grupo_trabajo->setEmail($user->getEmail());
$grupo_trabajo->setUserId($user->getId());
$grupo_trabajo->setGrupoId($solicitud->getGrupoId());
$grupo_trabajo->save();
$this->redirect('@list_working_groups');
} else {
return sfView::ERROR;
}
} else {
return sfView::ERROR;
}
} else {
return sfView::ERROR;
}
} else {
return sfView::ERROR;
}
} else {
return sfView::ERROR;
}
}
示例5: execute
//.........这里部分代码省略.........
// milliseconds
if (is_null($clipTo)) {
$clipTo = $this->getRequestParameter("clipTo", self::NO_CLIP_TO);
}
// milliseconds
if ($clipTo == 0) {
$clipTo = self::NO_CLIP_TO;
}
if (!is_numeric($clipTo) || $clipTo < 0) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'clipTo must be a positive number');
}
$seekFrom = $this->getRequestParameter("seekFrom", -1);
if ($seekFrom <= 0) {
$seekFrom = -1;
}
$seekFromBytes = $this->getRequestParameter("seekFromBytes", -1);
if ($seekFromBytes <= 0) {
$seekFromBytes = -1;
}
if ($fileParam && is_dir($path)) {
$path .= "/{$fileParam}";
kFileUtils::dumpFile($path, null, null);
KExternalErrors::dieGracefully();
} else {
if (!$isFlv || $clipTo == self::NO_CLIP_TO && $seekFrom < 0 && $seekFromBytes < 0) {
$limit_file_size = 0;
if ($clipTo != self::NO_CLIP_TO) {
if (strtolower($flavorAsset->getFileExt()) == 'mp4' && PermissionPeer::isValidForPartner(PermissionName::FEATURE_ACCURATE_SERVE_CLIPPING, $flavorAsset->getPartnerId())) {
$contentPath = myContentStorage::getFSContentRootPath();
$tempClipName = $version . '_' . $clipTo . '.mp4';
$tempClipPath = $contentPath . myContentStorage::getGeneralEntityPath("entry/tempclip", $flavorAsset->getIntId(), $flavorAsset->getId(), $tempClipName);
if (!file_exists($tempClipPath)) {
kFile::fullMkdir($tempClipPath);
$clipToSec = round($clipTo / 1000, 3);
$cmdLine = kConf::get("bin_path_ffmpeg") . " -i {$path} -vcodec copy -acodec copy -f mp4 -t {$clipToSec} -y {$tempClipPath} 2>&1";
KalturaLog::log("Executing {$cmdLine}");
$output = array();
$return_value = "";
exec($cmdLine, $output, $return_value);
KalturaLog::log("ffmpeg returned {$return_value}, output:" . implode("\n", $output));
}
if (file_exists($tempClipPath)) {
KalturaLog::log("Dumping {$tempClipPath}");
kFileUtils::dumpFile($tempClipPath);
} else {
KalturaLog::err('Failed to clip the file using ffmpeg, falling back to rough clipping');
}
}
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAsset->getId());
if ($mediaInfo && ($mediaInfo->getVideoDuration() || $mediaInfo->getAudioDuration() || $mediaInfo->getContainerDuration())) {
$duration = $mediaInfo->getVideoDuration() ? $mediaInfo->getVideoDuration() : ($mediaInfo->getAudioDuration() ? $mediaInfo->getAudioDuration() : $mediaInfo->getContainerDuration());
$limit_file_size = floor(@kFile::fileSize($path) * ($clipTo / $duration) * 1.2);
}
}
$renderer = kFileUtils::getDumpFileRenderer($path, null, null, $limit_file_size);
if (!$fileName) {
$this->storeCache($renderer, $flavorAsset->getPartnerId());
}
$renderer->output();
KExternalErrors::dieGracefully();
}
}
$audioOnly = $this->getRequestParameter("audioOnly");
// milliseconds
if ($audioOnly === '0') {
// audioOnly was explicitly set to 0 - don't attempt to make further automatic investigations
} elseif ($flvWrapper->getFirstVideoTimestamp() < 0) {
$audioOnly = true;
}
$bytes = 0;
if ($seekFrom !== -1 && $seekFrom !== 0) {
list($bytes, $duration, $firstTagByte, $toByte) = $flvWrapper->clip(0, -1, $audioOnly);
list($bytes, $duration, $fromByte, $toByte, $seekFromTimestamp) = $flvWrapper->clip($seekFrom, -1, $audioOnly);
$seekFromBytes = myFlvHandler::FLV_HEADER_SIZE + $flvWrapper->getMetadataSize($audioOnly) + $fromByte - $firstTagByte;
} else {
list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
}
$metadataSize = $flvWrapper->getMetadataSize($audioOnly);
$dataOffset = $metadataSize + myFlvHandler::getHeaderSize();
$totalLength = $dataOffset + $bytes;
list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
list($rangeFrom, $rangeTo, $rangeLength) = requestUtils::handleRangeRequest($totalLength);
if ($totalLength < 1000) {
// (actually $total_length is probably 13 or 143 - header + empty metadata tag) probably a bad flv maybe only the header - dont cache
requestUtils::sendCdnHeaders("flv", $rangeLength, 0);
} else {
requestUtils::sendCdnHeaders("flv", $rangeLength);
}
// dont inject cuepoint into the stream
$cuepointTime = 0;
$cuepointPos = 0;
try {
Propel::close();
} catch (Exception $e) {
$this->logMessage("serveFlavor: error closing db {$e}");
}
header("Content-Type: video/x-flv");
$flvWrapper->dump(self::CHUNK_SIZE, $fromByte, $toByte, $audioOnly, $seekFromBytes, $rangeFrom, $rangeTo, $cuepointTime, $cuepointPos);
KExternalErrors::dieGracefully();
}
示例6: executeEspejo_reportes
public function executeEspejo_reportes($tree_id, $list_data_indicador, $fecha_update)
{
// $tree_id = $request->getParameter('idTree');
// $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'),null);
if ($tree_id != 0) {
$tree_espejo = TreeScPeer::retrieveByPK($tree_id);
if (is_object($tree_espejo)) {
try {
$conn = Propel::getConnection();
$conn->beginTransaction();
$tree_bean = new TmpTreeSc();
$tree_bean->setConfigureFlag($tree_espejo->getConfigureFlag());
$tree_bean->setFlag("ok");
$tree_bean->save();
$criterio = new Criteria();
$criterio->add(IndicatorsScPeer::TREE_ID, $tree_espejo->getId());
$criterio->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE);
$criterio->addAscendingOrderByColumn(IndicatorsScPeer::ID);
$list_indicadores = IndicatorsScPeer::doSelect($criterio);
$list_relation = null;
foreach ($list_indicadores as $row) {
$indicator_bean = new TmpDataReports();
$indicator_bean->setIndicadorId($row->getId());
$indicator_bean->setValorMinimo($row->getValorMinimo());
$indicator_bean->setValorDeseado($row->getValorDeseado());
$indicator_bean->setValorOptimo($row->getValorOptimo());
$indicator_bean->setTreeId($tree_bean->getId());
$indicator_bean->setUltimoNodo($row->getUltimoNodo());
$indicator_bean->setUpdateAt($fecha_update);
$indicator_bean->setFlag("ok");
if ($row->getPreviousId() == 0) {
$indicator_bean->setPreviousId(0);
} else {
$id_relation = $this->return_relation_id($list_relation, $row->getPreviousId());
$indicator_bean->setPreviousId($id_relation);
}
if ($row->getParents() != "") {
$parents = $this->return_parent_relation($list_relation, $row->getParents());
$indicator_bean->setParents($parents);
}
//preguntar si es ultmo idicador
//->getUltimoNodo()
//si es ultimo nodo tengo que pasar la data actual
//a data que se esta creando ->
$indicator_bean->setConectoresConfigure($row->getConectoresConfigure());
$indicator_bean->save();
//actualizo el valor actual entregado
$relation = array('array' => '' . $row->getId() . '-' . $indicator_bean->getId() . '');
$list_relation[] = $relation;
}
foreach ($list_data_indicador as $obj_data) {
$criteria = new Criteria();
$id = $this->return_relation_id($list_relation, $obj_data->getIndicadorId());
$criteria->add(TmpDataReportsPeer::ID, $id);
$obj_update_tmp = TmpDataReportsPeer::doSelectOne($criteria);
$obj_update_tmp->setData($obj_data->getData());
$obj_update_tmp->save();
}
$conn->commit();
$conn = Propel::close();
// VOY A DEVOLVER UN ARREGLO CON DOS VALORES 1) ID DEL TREE TEMPORAL, 2) LA LISTA DE LA RELACION
$result = array('array' => $tree_bean->getId(), "lista" => $list_relation);
return $result;
//$this->list_relation = $list_relation;
//$this->redirect('@edit_strategy?id_tree='.$tree_bean->getId());
} catch (Exception $e) {
$conn->rollBack();
// $this->message = $e->getMessage();
$conn = Propel::close();
return sfView::ERROR;
}
} else {
// $this->message = 'tree not definitive';
$conn = Propel::close();
return sfView::ERROR;
}
} else {
// $this->message = 'session expired';
$conn = Propel::close();
return sfView::ERROR;
}
}
示例7: closeDbConnections
public static function closeDbConnections()
{
// close all opened db connetion while we end an action with a long executing operation such as dumping a file.
// this will limit the number of concurrent db connections as dumping a file make take a long time
try {
Propel::close();
} catch (Exception $e) {
$this->logMessage("closeDbConnections: error closing db {$e}");
}
}
示例8: execute
//.........这里部分代码省略.........
$ll_url = requestUtils::getCdnHost() . "/s{$request}" . $flv_extension;
$secret = kConf::get("limelight_madiavault_password");
$expire = "&e=" . (time() + 120);
$ll_url .= $expire;
$fs = $seek_from_bytes == -1 ? "" : "&fs={$seek_from_bytes}";
$ll_url .= "&h=" . md5("{$secret}{$ll_url}") . $fs;
//header("Location: $ll_url");
$this->redirect($ll_url);
} else {
if ($cdn_name == "level3") {
$level3_url = $request . $flv_extension;
if ($entry->getSecurityPolicy()) {
$level3_url = "/s{$level3_url}";
// set expire time in GMT hence the date("Z") offset
$expire = "&nva=" . strftime("%Y%m%d%H%M%S", time() - date("Z") + 30);
$level3_url .= $expire;
$secret = kConf::get("level3_authentication_key");
$hash = "0" . substr(self::hmac('sha1', $secret, $level3_url), 0, 20);
$level3_url .= "&h={$hash}";
}
$level3_url .= $seek_from_bytes == -1 ? "" : "&start={$seek_from_bytes}";
header("Location: {$level3_url}");
die;
} else {
if ($cdn_name == "akamai") {
$akamai_url = $request . $flv_extension;
// if for some reason we didnt set our accurate $seek_from_timestamp reset it to the requested seek_from
if ($seek_from_timestamp == -1) {
$seek_from_timestamp = $seek_from;
}
$akamai_url .= $seek_from_bytes == -1 ? "" : "&aktimeoffset=" . floor($seek_from_timestamp / 1000);
header("Location: {$akamai_url}");
die;
}
}
}
// a seek request without a supporting cdn - we need to send the answer from our server
if ($seek_from_bytes !== -1 && $via_header === null) {
$this->dump_from_byte = $seek_from_bytes;
}
}
}
// always add the file suffix to the request (needed for scrubbing by some cdns,
// and also breaks without extension on some corporate antivirus).
// we add the the novar paramter since a leaving a trailing "?" will be trimmed
// and then the /seek_from request will result in another url which level3
// will try to refetch from the origin
// note that for streamer we dont add the file extension
if ($streamer != "rtmp" && strpos($request, $flv_extension) === false) {
// a seek request without a supporting cdn - we need to send the answer from our server
if ($seek_from_bytes !== -1 && $via_header === null) {
$request .= "/seek_from_bytes/{$seek_from_bytes}";
}
requestUtils::sendCdnHeaders("flv", 0);
header("Location: {$request}" . $flv_extension);
die;
}
// mp4
if (!$isFlv) {
kFile::dumpFile($path);
}
$this->logMessage("flvclipperAction: serving file [{$path}] entry_id [{$entry_id}] clip_from [{$clip_from}] clip_to [{$clip_to}]", "warning");
if ($audio_only === '0') {
// audio_only was explicitly set to 0 - don't attempt to make further automatic investigations
} elseif ($flv_wrapper->getFirstVideoTimestamp() < 0) {
$audio_only = true;
}
//$start = microtime(true);
list($bytes, $duration, $from_byte, $to_byte, $from_ts, $cuepoint_pos) = myFlvStaticHandler::clip($path, $clip_from, $clip_to, $audio_only);
$metadata_size = $flv_wrapper->getMetadataSize($audio_only);
$this->from_byte = $from_byte;
$this->to_byte = $to_byte;
//$end1 = microtime(true);
//$this->logMessage( "flvclipperAction: serving file [$path] entry_id [$entry_id] bytes [$bytes] duration [$duration] [$from_byte]->[$to_byte]" , "warning" );
//$this->logMessage( "flvclipperAction: serving file [$path] t1 [" . ( $end1-$start) . "]");
$data_offset = $metadata_size + myFlvHandler::getHeaderSize();
// if we're returning a partial file adjust the total size:
// substract the metadata and bytes which are not delivered
if ($this->dump_from_byte >= $data_offset && !$audio_only) {
$bytes -= $metadata_size + max(0, $this->dump_from_byte - $data_offset);
}
$this->total_length = $data_offset + $bytes;
//echo " $bytes , $duration ,$from_byte , $to_byte, $cuepoint_pos\n"; die;
$this->cuepoint_time = 0;
$this->cuepoint_pos = 0;
if ($streamer == "chunked" && $clip_to != 2147483647) {
$this->cuepoint_time = $clip_to - 1;
$this->cuepoint_pos = $cuepoint_pos;
$this->total_length += myFlvHandler::CUEPOINT_TAG_SIZE;
}
//$this->logMessage( "flvclipperAction: serving file [$path] entry_id [$entry_id] bytes with header & md [" . $this->total_length . "] bytes [$bytes] duration [$duration] [$from_byte]->[$to_byte]" , "warning" );
$this->flv_wrapper = $flv_wrapper;
$this->audio_only = $audio_only;
try {
Propel::close();
} catch (Exception $e) {
$this->logMessage("flvclipperAction: error closing db {$e}");
}
return sfView::SUCCESS;
}
示例9: getPropelConnection
/**
* Returns a writable propel connection to the database of the Crontab.
*
* @param bool $reconnect Whether to force a new connection.
*
* @return PDO
*/
protected function getPropelConnection($reconnect = false)
{
static $connection;
if ($reconnect or empty($connection)) {
if ($reconnect) {
Propel::close();
}
$connection = Propel::getConnection(CrontabPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
return $connection;
}
示例10: shutdown
public static function shutdown()
{
Propel::close();
}
示例11: fork
/**
* Fork the process into two
* You can create an optional method called preFork() which is called before the fork
* Also an optional method called postFork() which is called after the fork on any remaining processes
* (ie if you choose to daemonize then the original foreground process will not call the postFork() method)
*
* @param bool $daemonize kill the parent (original) process and let the new child run
*
* @return void
*/
protected function fork($daemonize = false)
{
if ($this->node !== 0) {
return false;
}
// call any user created preFork method
if (method_exists($this, 'preFork')) {
$this->preFork();
}
// force Propel to close connections so that it will reconnect on next query
if (class_exists('\\Propel')) {
\Propel::close();
}
$pid = pcntl_fork();
switch ($pid) {
case -1:
Logger::emergency('Unable to fork process');
return;
case 0:
// this is the child
$this->node++;
break;
default:
// we are the original process
if ($this->node == 0) {
\Cli\line('Child node : pid=%y%s%n', $pid);
if ($daemonize) {
// exit;
} else {
$this->pid[] = $pid;
}
return;
}
}
// promote the daemon process so it doesn't die because the parent has
if ($daemonize && posix_setsid() === -1) {
Logger::critical('Error creating daemon as session leader');
exit(1);
}
fclose(STDIN);
fclose(STDOUT);
fclose(STDERR);
$this->stdIn = fopen('/dev/null', 'r');
// set fd/0
$this->stdOut = fopen('/dev/null', 'w');
// set fd/1
$this->stdErr = fopen('php://stdout', 'w');
// a hack to duplicate fd/1 to 2
// Silence any console output from the logger
Logger::setSilentConsole(true);
// call any user created postFork method
if (method_exists($this, 'postFork')) {
$this->postFork();
}
}
示例12: evaluar_solicitud
private function evaluar_solicitud($email, $grupo, $userBean)
{
//solo puede enviar otra solicitud a la misma persona si
//-es otra solicitud de otro grupo
//-si el flag es 2 == Solicitud vencida
$criterio_solicitud = new Criteria();
$criterio_solicitud->add(SolicitudGrupoTrabajoScPeer::GRUPO_ID, $grupo);
$criterio_solicitud->add(SolicitudGrupoTrabajoScPeer::EMAIL, '%' . $email . '%', Criteria::LIKE);
//FLAG,'1' == activa
$criterio_solicitud->add(SolicitudGrupoTrabajoScPeer::FLAG, '%estado":true%', Criteria::LIKE);
$cantidad_registros = SolicitudGrupoTrabajoScPeer::doCount($criterio_solicitud);
try {
$con = Propel::getConnection();
$con->beginTransaction();
if ($cantidad_registros > 0) {
//no le envio solicitud
$obj = array("success" => true, "message" => "no le envio solicitud");
$con = Propel::close();
return $obj;
} else {
$solicitudBean = new SolicitudGrupoTrabajoSc();
$solicitudBean->setGrupoId($grupo);
$solicitudBean->setEmail($email);
$solicitudBean->setCreateAt(time());
$solicitudBean->setUpdateAt(time());
$solicitudBean->setUserId($userBean->getId());
//formar el token
$token = md5($grupo . $email . rand($userBean->getId(), 1000));
$solicitudBean->setToken($token);
$solicitudBean->setFlag(json_encode(array("estado" => true, "respuesta" => false)));
$solicitudBean->setRespondido(0);
$solicitudBean->save();
try {
$message = $this->getMailer()->compose();
$message->setSubject('Te invintaron a unirte a practil-scoredcard');
$message->setTo($email);
$message->setFrom(array('cquevedo@esfera.pe' => 'Practil'));
$html = $this->getPartial('send_email/send_invitation_group', array('uri' => sfConfig::get('app_url_scorecard') . 'confirmation/confirmation_group?token=' . $token . '&email=' . $email . '&group_id=' . $grupo));
$message->setBody($html, 'text/html');
$this->getMailer()->send($message);
$con->commit();
$con = Propel::close();
$obj = array("success" => true, "message" => "le envie solicitud");
return $obj;
} catch (Exception $e) {
$con->rollBack();
$con = Propel::close();
$obj = array("success" => false, "message" => $e->getMessage());
return $obj;
}
}
} catch (Exception $e) {
$con->rollBack();
$con = Propel::close();
$obj = array("success" => false, "message" => "se general");
return $obj;
}
}
示例13: dbShutdown
public static function dbShutdown()
{
$databaseManager = new sfDatabaseManager();
$databaseManager->shutdown();
Propel::close();
}
示例14: executeCreate_mirror_tree
public function executeCreate_mirror_tree(sfWebRequest $request)
{
$tree_id = $request->getParameter('idTree');
$user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
if ($user != null) {
$tree_current = TreeScPeer::retrieveByPK($tree_id);
if (is_object($tree_current)) {
try {
$conn = Propel::getConnection();
$conn->beginTransaction();
$tree_bean = new TreeSc();
$tree_bean->setName($tree_current->getName());
$tree_bean->setUserId($tree_current->getUserId());
$tree_bean->setConfigureFlag($tree_current->getConfigureFlag());
$tree_bean->setConfigureDesign($tree_current->getConfigureDesign());
$tree_bean->setCreateAt(time());
$tree_bean->setUpdateAt(time());
$tree_bean->setFlag($tree_current->getFlag());
$tree_bean->setProduccion('not');
$tree_bean->setGrupoTrabajoId($tree_current->getGrupoTrabajoId());
$tree_bean->setPeriodoId($tree_current->getPeriodoId());
$tree_bean->save();
$tree_user_bean = new TreeUser();
$tree_user_bean->setUserId($tree_bean->getUserId());
$tree_user_bean->setTreeId($tree_bean->getId());
$tree_user_bean->save();
$criterio = new Criteria();
$criterio->add(IndicatorsScPeer::TREE_ID, $tree_current->getId());
$criterio->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE);
$criterio->addAscendingOrderByColumn(IndicatorsScPeer::ID);
$list_indicadores = IndicatorsScPeer::doSelect($criterio);
$list_relation = null;
foreach ($list_indicadores as $row) {
$indicator_bean = new IndicatorsSc();
$indicator_bean->setTitulo($row->getTitulo());
$indicator_bean->setDescripcion($row->getDescripcion());
$indicator_bean->setValorMinimo($row->getValorMinimo());
$indicator_bean->setValorDeseado($row->getValorDeseado());
$indicator_bean->setValorOptimo($row->getValorOptimo());
$indicator_bean->setResponsableId($row->getResponsableId());
$indicator_bean->setTreeId($tree_bean->getId());
$indicator_bean->setEmailResponsable($row->getEmailResponsable());
$indicator_bean->setUltimoNodo($row->getUltimoNodo());
$indicator_bean->setDetNetworkAttributeId($row->getDetNetworkAttributeId());
$indicator_bean->setUsernameInNetwork($row->getUsernameInNetwork());
$indicator_bean->setGaFecIni($row->getGaFecIni());
$indicator_bean->setGaFecFin($row->getGaFecFin());
if ($row->getPreviousId() == 0) {
$indicator_bean->setPreviousId(0);
} else {
$id_relation = $this->return_relation_id($list_relation, $row->getPreviousId());
$indicator_bean->setPreviousId($id_relation);
}
if ($row->getParents() != "") {
$parents = $this->return_parent_relation($list_relation, $row->getParents());
$indicator_bean->setParents($parents);
}
$indicator_bean->setFlag($row->getFlag());
$indicator_bean->setConectoresConfigure($row->getConectoresConfigure());
$indicator_bean->save();
$relation = array('array' => '' . $row->getId() . '-' . $indicator_bean->getId() . '');
$list_relation[] = $relation;
}
// $conn->rollBack();
$tree_current->setFlag(2);
$tree_current->save();
$conn->commit();
$conn = Propel::close();
$this->list_relation = $list_relation;
$this->redirect('@edit_strategy?id_tree=' . $tree_bean->getId());
} catch (Exception $e) {
$conn->rollBack();
$this->message = $e->getMessage();
$conn = Propel::close();
return sfView::ERROR;
}
} else {
$this->message = 'tree not definitive';
$conn = Propel::close();
return sfView::ERROR;
}
} else {
$this->message = 'session expired';
$conn = Propel::close();
return sfView::ERROR;
}
}
示例15: is_the_last_record
public function is_the_last_record($data)
{
$connection = Propel::getConnection();
$query = 'SELECT MAX(group_data) AS max FROM data_indicadores WHERE indicador_id = ' . $data->getIndicadorId();
$statement = $connection->prepare($query);
$statement->execute();
$row = $statement->fetch();
$ultimo = $row['max'];
$connection = Propel::close();
if ($ultimo == $data->getGroupData()) {
return true;
} else {
return false;
}
}