本文整理汇总了PHP中Doctrine_Event::getParams方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Event::getParams方法的具体用法?PHP Doctrine_Event::getParams怎么用?PHP Doctrine_Event::getParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Event
的用法示例。
在下文中一共展示了Doctrine_Event::getParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preStmtExecute
public function preStmtExecute(Doctrine_Event $event)
{
// Check if the administrator has enabled the query logging feature
if (Settings::findbyParam('debug_queries')) {
$breadcrumps = array();
$query = $event->getQuery();
$params = $event->getParams();
$callers = array_reverse(debug_backtrace(), true);
$callers = array_slice($callers, 4, count($callers) - 10);
foreach ($callers as $caller) {
$class = !empty($caller['class']) ? $caller['class'] : null;
$breadcrumps[] = $class . "->" . $caller['function'];
}
$strBreadcrump = "System: " . implode(" / ", $breadcrumps);
//the below makes some naive assumptions about the queries being logged
while (sizeof($params) > 0) {
$param = array_shift($params);
if (!is_numeric($param)) {
$param = sprintf("'%s'", $param);
}
$query = substr_replace($query, $param, strpos($query, '?'), 1);
}
Shineisp_Commons_Utilities::log($query, "queries.log");
Shineisp_Commons_Utilities::log($strBreadcrump, "debug.log", Zend_Log::DEBUG);
// Increase query counter
$queryCount = Shineisp_Registry::isRegistered('querycount') ? Shineisp_Registry::get('querycount') : 0;
$queryCount = $queryCount + 1;
Shineisp_Registry::set('querycount', $queryCount);
}
}
示例2: preDqlDelete
public function preDqlDelete(Doctrine_Event $event)
{
$params = $event->getParams();
$tmpQuery = clone $event->getQuery();
$subQuery = $tmpQuery->select($params['alias'] . '.' . $params['component']['table']->getIdentifier())->getDql();
if (!in_array($params['alias'], $tmpQuery->getDqlPart('from'))) {
return false;
}
$targets = $this->detectCascadingTargets($params['component']['table']);
foreach ($targets as $target) {
$table = Doctrine::getTable($target['table']);
$relation = $table->getRelation($target['aliasFrom']);
$localField = $relation->getLocalFieldName();
$q = $table->createQuery();
$q = $q->where($q->getRootAlias() . '.' . $localField . ' IN (' . $subQuery . ')');
switch (strtolower($target['delete'])) {
case 'cascade':
$q->delete()->execute();
break;
case 'set null':
$q->update()->set($localField, '?', array(null))->execute();
break;
default:
// do nothing
}
}
}
示例3: preStmtExecute
public function preStmtExecute(Doctrine_Event $event)
{
$log = '{sfDoctrine Pre-execute} executePreparedQuery : ' . $event->getQuery();
if ($params = $event->getParams()) {
$log .= ' - (' . implode(', ', $params) . ' )';
}
sfContext::getInstance()->getLogger()->log($log);
$sqlTimer = sfTimerManager::getTimer('Database (Doctrine)');
}
示例4: preDqlSelect
/**
* Adds categories relation specific joins.
*
* @param Doctrine_Event $event Event.
*
* @return void
*/
public function preDqlSelect(Doctrine_Event $event)
{
$query = $event->getQuery();
$params = $event->getParams();
// aliases must be specific to entities
$aliasCategories = $params['alias'] . 'Catmapobj';
$dql = $params['alias'] . '.Categories ' . $aliasCategories . ' INDEXBY ' . $aliasCategories . '.reg_property';
if (!$query->contains($dql)) {
$query->leftJoin($dql)->leftJoin($aliasCategories . '.Category ' . $params['alias'] . 'Cat');
}
}
示例5: preDqlSelect
public function preDqlSelect(Doctrine_Event $event)
{
if (!opActivateBehavior::getEnabled()) {
return null;
}
$params = $event->getParams();
$field = $params['alias'] . '.is_active';
$query = $event->getQuery();
if (!$query->contains($field)) {
$query->addWhere($field . ' = ? OR ' . $field . ' IS NULL', array(true));
}
}
示例6: preDqlDelete
public function preDqlDelete(Doctrine_Event $event)
{
$params = $event->getParams();
$query = $event->getQuery();
$table = $params['component']['table'];
$identifier = $table->getIdentifier();
$tmpQuery = clone $event->getQuery();
$subQuery = $tmpQuery->select($params['alias'] . '.' . $identifier);
$records = $subQuery->execute();
if ($records instanceof Doctrine_Collection && $records->count()) {
$q = Doctrine::getTable('ActivityData')->createQuery()->where('foreign_table = ?', $table->getTableName())->andWhereIn('foreign_id', array_values($records->toKeyValueArray($identifier, $identifier)))->delete()->execute();
}
}
示例7: preStmtExecute
/**
* preStmtExecute
*
* @param string $Doctrine_Event
* @return void
*/
public function preStmtExecute(Doctrine_Event $event)
{
$query = $event->getQuery();
$params = $event->getParams();
foreach ($params as $key => $value) {
if (is_numeric($key)) {
// it's a '?'
$query = preg_replace('/\\?/', "'" . $value . "'", $query, 1);
} else {
$params[$key] = "'" . $value . "'";
}
}
$this->queries[] = strtr($query, $params);
}
示例8: preStmtExecute
public function preStmtExecute(Doctrine_Event $event)
{
$query = $event->getQuery();
$params = $event->getParams();
//the below makes some naive assumptions about the queries being logged
while (sizeof($params) > 0) {
$param = array_shift($params);
if (!is_numeric($param)) {
$param = sprintf("'%s'", $param);
}
$query = substr_replace($query, $param, strpos($query, '?'), 1);
debug($query);
}
}
示例9: preDqlSelect
/**
* (non-PHPdoc)
* @see branch/vendors/doctrine/Doctrine/Record/Doctrine_Record_Listener#preDqlSelect()
* add a date constraint to every query before it's executed
* @param Doctrine_Event $event
* @return void
*/
public function preDqlSelect(Doctrine_Event $event)
{
$query = $event->getQuery();
if (get_class($query) == Doctrine_Template_Temporal::QUERY_CLASS_NAME) {
// is this a Temporal query?
$query_date = $query->getQueryDate($this->date_format);
if ($query_date !== false) {
// false means 'ignore query date'
$params = $event->getParams();
$eff_date_field = $params['alias'] . '.' . $this->_options['eff_date'];
$exp_date_field = $params['alias'] . '.' . $this->_options['exp_date'];
$query->addWhere($eff_date_field . ' <= ?', $query_date);
$query->addWhere("({$exp_date_field} IS NULL OR {$exp_date_field} > ?)", $query_date);
}
}
}
示例10: preDqlUpdate
/**
* Set the updated field for dql update queries
*
* @param Doctrine_Event $evet
* @return void
*/
public function preDqlUpdate(Doctrine_Event $event)
{
try {
$guard_user = sfContext::getInstance()->getUser()->getGuardUser();
} catch (Exception $e) {
return;
}
if (!$this->_options['updated']['disabled']) {
$params = $event->getParams();
$updatedName = $event->getInvoker()->getTable()->getFieldName($this->_options['updated']['name']);
$field = $params['alias'] . '.' . $updatedName;
$query = $event->getQuery();
if (!$query->contains($field)) {
$query->set($field, '?', $guard_user);
}
}
}
示例11: preDqlSelect
/**
* Pre SELECT
*/
public function preDqlSelect(Doctrine_Event $event)
{
$query = $event->getQuery();
$params = $event->getParams();
$alias = $params['alias'];
$limit = $query->getDqlPart('limit');
$limit = count($limit) ? (int) $limit[0] : 0;
// Если не указан LIMIT 1
// Если не указан SELECT
// Если это не подзапрос
if (1 != $limit && !$query->getDqlPart('select') && !$query->isSubquery()) {
$skip = $this->getOption('skip');
$columns = $event->getInvoker()->getTable()->getColumnNames();
$columns = array_diff($columns, $skip);
$select = $alias . '.' . join(', ' . $alias . '.', $columns);
$query->select($select);
}
}
示例12: preStmtExecute
/**
* Logs a statement execute on behalf of the statement.
*
* @param Doctrine_Event $event
*/
public function preStmtExecute(Doctrine_Event $event)
{
if ($this->options['logging']) {
$this->dispatcher->notify(new sfEvent($event->getInvoker(), 'application.log', array(sprintf('execute : %s - (%s)', $event->getQuery(), join(', ', self::fixParams($event->getParams()))))));
}
sfTimerManager::getTimer('Database (Doctrine)');
$args = func_get_args();
$this->__call(__FUNCTION__, $args);
}
示例13: preDqlSelect
/**
* Implement preDqlSelect() hook and add the deleted flag to all queries for which this model
* is being used in.
*
* @param Doctrine_Event $event
* @return void
*/
public function preDqlSelect(Doctrine_Event $event)
{
$params = $event->getParams();
$field = $params['alias'] . '.' . $this->_options['name'];
$query = $event->getQuery();
// We only need to add the restriction if:
// 1 - We are in the root query
// 2 - We are in the subquery and it defines the component with that alias
if ((!$query->isSubquery() || $query->isSubquery() && $query->contains(' ' . $params['alias'] . ' ')) && !$query->contains($field)) {
if ($this->_options['type'] == 'timestamp') {
$query->addPendingJoinCondition($params['alias'], $field . ' IS NULL');
} else {
if ($this->_options['type'] == 'boolean') {
$query->addPendingJoinCondition($params['alias'], $field . ' = ' . $query->getConnection()->convertBooleans(false));
}
}
}
}
示例14: preDqlUpdate
/**
* Set the updated field for dql update queries
*
* @param Doctrine_Event $evet
* @return void
*/
public function preDqlUpdate(Doctrine_Event $event)
{
if (!$this->_options['updated']['disabled']) {
$params = $event->getParams();
$updatedName = $event->getInvoker()->getTable()->getFieldName($this->_options['updated']['name']);
$field = $params['alias'] . '.' . $updatedName;
$query = $event->getQuery();
if (!$query->contains($field)) {
$query->set($field, '?', $this->getTimestamp('updated', $event->getInvoker()->getTable()->getConnection()));
}
}
}
示例15: preDqlSelect
/**
* Implement preDqlSelect() hook and add the deleted flag to all queries for which this model
* is being used in.
*
* @param Doctrine_Event $event
* @return void
*/
public function preDqlSelect(Doctrine_Event $event)
{
$params = $event->getParams();
$field = $params['alias'] . '.' . $this->_options['name'];
$query = $event->getQuery();
if (!$query->contains($field)) {
$query->addWhere($field . ' = 0 OR ' . $field . ' IS NULL');
}
}