當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。