当前位置: 首页>>代码示例>>PHP>>正文


PHP base::get_connection方法代码示例

本文整理汇总了PHP中base::get_connection方法的典型用法代码示例。如果您正苦于以下问题:PHP base::get_connection方法的具体用法?PHP base::get_connection怎么用?PHP base::get_connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在base的用法示例。


在下文中一共展示了base::get_connection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $dql = 'SELECT u FROM Phraseanet:User u WHERE u.nonce IS NULL';
     $q = $app['orm.em']->createQuery($dql);
     $q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
     $users = $q->getResult();
     $n = 0;
     foreach ($users as $user) {
         $user->setNonce($app['random.medium']->generateString(64));
         $app['orm.em']->persist($user);
         $n++;
         if ($n % 100 === 0) {
             $app['orm.em']->flush();
         }
     }
     $app['orm.em']->flush();
     $sql = 'SELECT task_id, `class` FROM task2';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $sql = 'UPDATE task2 SET `class` = :class WHERE task_id = :task_id';
     $stmt = $appbox->get_connection()->prepare($sql);
     foreach ($rs as $row) {
         if (strpos($row['class'], 'task_period_') !== false) {
             continue;
         }
         $params = [':task_id' => $row['task_id'], ':class' => str_replace('task_', 'task_period_', $row['class'])];
         $stmt->execute($params);
     }
     $stmt->closeCursor();
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:36,代码来源:320alpha2a.php

示例2: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'SELECT `key`, `value` FROM `registry`
             WHERE `key` = "GV_X_Accel_Redirect"
                 OR `key` = "GV_X_Accel_Redirect_mount_point"
                 OR `key` = "GV_modxsendfile"';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $registry = ['GV_X_Accel_Redirect' => null, 'GV_X_Accel_Redirect_mount_point' => null, 'GV_modxsendfile' => null];
     foreach ($rows as $row) {
         $registry[$row['key']] = $row['value'];
     }
     $xsendfilePath = $registry['GV_X_Accel_Redirect'];
     $xsendfileMountPoint = $registry['GV_X_Accel_Redirect_mount_point'];
     $config = $app['configuration.store']->setDefault('xsendfile')->getConfig();
     $config['xsendfile']['enabled'] = (bool) $registry['GV_modxsendfile'];
     $config['xsendfile']['type'] = $config['xsendfile']['enabled'] ? 'nginx' : '';
     if (null !== $xsendfilePath && null !== $xsendfileMountPoint) {
         $config['xsendfile']['mapping'] = [['directory' => $xsendfilePath, 'mount-point' => $xsendfileMountPoint]];
     }
     $app['configuration.store']->setConfig($config);
     $toRemove = ['GV_X_Accel_Redirect', 'GV_X_Accel_Redirect_mount_point', 'GV_modxsendfile'];
     $sql = 'DELETE FROM registry WHERE `key` = :k';
     $stmt = $appbox->get_connection()->prepare($sql);
     foreach ($toRemove as $registryKey) {
         $stmt->execute([':k' => $registryKey]);
     }
     $stmt->closeCursor();
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:35,代码来源:380alpha13a.php

示例3: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $sql = 'UPDATE record r, subdef s
             SET r.mime = s.mime
             WHERE r.record_id = s.record_id
               AND s.name="document"';
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     $sql = 'UPDATE subdef s, record r
             SET s.updated_on = r.moddate, s.created_on = r.credate
             WHERE s.record_id = r.record_id';
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     $sql = 'UPDATE subdef SET `name` = LOWER( `name` )';
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     $dom = $databox->get_dom_structure();
     $xpath = $databox->get_xpath_structure();
     $nodes = $xpath->query('//record/subdefs/subdefgroup/subdef');
     foreach ($nodes as $node) {
         $name = mb_strtolower(trim($node->getAttribute('name')));
         if ($name === '') {
             continue;
         }
         $node->setAttribute('name', $name);
     }
     $databox->saveStructure($dom);
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:35,代码来源:320alpha6a.php

示例4: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $sql = 'SELECT id, src FROM metadatas_structure';
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $update = [];
     $tagDirname = new \Alchemy\Phrasea\Metadata\Tag\TfDirname();
     $tagBasename = new \Alchemy\Phrasea\Metadata\Tag\TfBasename();
     foreach ($rs as $row) {
         if (strpos(strtolower($row['src']), 'tf-parentdir') !== false) {
             $update[] = ['id' => $row['id'], 'src' => $tagDirname->getTagname()];
         }
         if (strpos(strtolower($row['src']), 'tf-filename') !== false) {
             $update[] = ['id' => $row['id'], 'src' => $tagBasename->getTagname()];
         }
     }
     $sql = 'UPDATE metadatas_structure SET src = :src
             WHERE id = :id';
     $stmt = $databox->get_connection()->prepare($sql);
     foreach ($update as $row) {
         $stmt->execute([':src' => $row['src'], ':id' => $row['id']]);
     }
     $stmt->closeCursor();
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:30,代码来源:370alpha4a.php

示例5: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'SELECT `value` FROM `registry` WHERE `key` = "GV_i18n_service"';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $row = $stmt->fetch(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     if (null !== $row && false !== strpos($row['value'], 'localization.webservice.alchemyasp.com')) {
         $sql = 'UPDATE `registry` SET `value` = "http://geonames.alchemyasp.com/" WHERE `key` = "GV_i18n_service"';
         $stmt = $appbox->get_connection()->prepare($sql);
         $stmt->execute();
         $stmt->closeCursor();
     }
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:18,代码来源:381alpha2a.php

示例6: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $conn = $databox->get_connection();
     $sql = 'SELECT value FROM pref WHERE prop = "structure"';
     $stmt = $conn->prepare($sql);
     $stmt->execute();
     $result = $stmt->fetch(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     if (!$result) {
         throw new \RuntimeException('Unable to find structure');
     }
     $DOMDocument = new DOMDocument();
     $DOMDocument->loadXML($result['value']);
     $XPath = new DOMXPath($DOMDocument);
     foreach ($XPath->query('/record/subdefs/subdefgroup/subdef/delay') as $delay) {
         $delay->nodeValue = min(500, max(50, (int) $delay->nodeValue * 400));
     }
     foreach ($XPath->query('/record/subdefs/subdefgroup/subdef/acodc') as $acodec) {
         if ($acodec->nodeValue == 'faac') {
             $acodec->nodeValue = 'libvo_aacenc';
         }
     }
     $sql = 'UPDATE pref SET value = :structure WHERE prop = "structure"';
     $stmt = $conn->prepare($sql);
     $stmt->execute([':structure' => $DOMDocument->saveXML()]);
     $stmt->closeCursor();
     return true;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:31,代码来源:370alpha1a.php

示例7: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $sql = "UPDATE metadatas_structure SET `aggregable`=20 WHERE `aggregable`=1";
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:10,代码来源:390alpha22a.php

示例8: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $sql = "SHOW INDEX FROM metadatas_structure WHERE KEY_NAME = 'sorter'";
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     if (count($rows) === 0) {
         return true;
     }
     $sql = "DROP INDEX sorter ON  metadatas_structure";
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:19,代码来源:381alpha1b.php

示例9: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     if (!$this->hasSessionTable($app)) {
         return true;
     }
     // Remove deleted users sessions
     $sql = 'SELECT s.id FROM `Sessions` s INNER JOIN Users u ON (u.id = s.user_id) WHERE u.deleted = 1';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     foreach ($rows as $row) {
         if (null !== ($session = $app['repo.sessions']->find($row['id']))) {
             $app['orm.em']->remove($session);
         }
     }
     // Remove API sessions
     $query = $app['orm.em']->createQuery('SELECT s FROM Phraseanet:Session s WHERE s.user_agent LIKE :guzzle');
     $query->setParameter(':guzzle', 'Guzzle%');
     foreach ($query->getResult() as $session) {
         $app['orm.em']->remove($session);
     }
     $app['orm.em']->flush();
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:28,代码来源:383alpha1a.php

示例10: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'DELETE FROM Tasks';
     $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     $sql = 'SELECT task_id, active, crashed, name, class, settings FROM task2';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     foreach ($rs as $row) {
         try {
             $job = $this->createJob($app, $row['class']);
         } catch (\RuntimeException $e) {
             continue;
         }
         $settings = simplexml_load_string($row['settings']);
         $period = $job->getEditor()->getDefaultPeriod();
         if ($settings->period) {
             $period = (int) $settings->period;
             unset($settings->period);
             $row['settings'] = $settings->asXML();
         }
         $task = new Task();
         $task->setCrashed($row['crashed'])->setJobId($job->getJobId())->setName($row['name'])->setPeriod($period)->setSettings($row['settings'])->setStatus($row['active'] ? Task::STATUS_STARTED : Task::STATUS_STOPPED);
         $app['EM']->persist($task);
     }
     $app['EM']->flush();
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:33,代码来源:390alpha8a.php

示例11: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $sql = "UPDATE log_docs SET `action`='mail' WHERE `action`='download' AND LOCATE('@', comment)";
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     return true;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:10,代码来源:384alpha5a.php

示例12: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'SELECT id, `usage`
             FROM `order`';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $sql = 'UPDATE `order` SET `usage` = :usage
             WHERE id = :id';
     $stmt = $appbox->get_connection()->prepare($sql);
     foreach ($rs as $row) {
         $stmt->execute([':usage' => strip_tags($row['usage']), ':id' => $row['id']]);
     }
     $stmt->closeCursor();
     return true;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:20,代码来源:380alpha10a.php

示例13: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'DELETE FROM basusr WHERE actif = "0"';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     return true;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:11,代码来源:320alpha8a.php

示例14: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'SELECT base_id, usr_id FROM order_masters';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $sql = 'UPDATE basusr SET order_master="1"
             WHERE base_id = :base_id
               AND usr_id = :usr_id';
     $stmt = $appbox->get_connection()->prepare($sql);
     foreach ($rs as $row) {
         $params = [':base_id' => $row['base_id'], ':usr_id' => $row['usr_id']];
         $stmt->execute($params);
     }
     $stmt->closeCursor();
     return true;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:21,代码来源:320alpha5a.php

示例15: apply

 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $sql = 'UPDATE record SET parent_record_id = "1"
             WHERE parent_record_id != "0"';
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     return true;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:12,代码来源:320alpha1a.php


注:本文中的base::get_connection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。