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


PHP Connection::fetchColumn方法代码示例

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


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

示例1: setValue

 /**
  * sets a value in the preferences
  * @param string $user user
  * @param string $app app
  * @param string $key key
  * @param string $value value
  * @param string $preCondition only set value if the key had a specific value before
  * @return bool true if value was set, otherwise false
  *
  * Adds a value to the preferences. If the key did not exist before, it
  * will be added automagically.
  */
 public function setValue($user, $app, $key, $value, $preCondition = null)
 {
     // Check if the key does exist
     $query = 'SELECT `configvalue` FROM `*PREFIX*preferences`' . ' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?';
     $oldValue = $this->conn->fetchColumn($query, array($user, $app, $key));
     $exists = $oldValue !== false;
     if ($oldValue === strval($value)) {
         // no changes
         return true;
     }
     $affectedRows = 0;
     if (!$exists && $preCondition === null) {
         $data = array('userid' => $user, 'appid' => $app, 'configkey' => $key, 'configvalue' => $value);
         $affectedRows = $this->conn->insert('*PREFIX*preferences', $data);
     } elseif ($exists) {
         $data = array($value, $user, $app, $key);
         $sql = "UPDATE `*PREFIX*preferences` SET `configvalue` = ?" . " WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?";
         if ($preCondition !== null) {
             if (\OC_Config::getValue('dbtype', 'sqlite') === 'oci') {
                 //oracle hack: need to explicitly cast CLOB to CHAR for comparison
                 $sql .= " AND to_char(`configvalue`) = ?";
             } else {
                 $sql .= " AND `configvalue` = ?";
             }
             $data[] = $preCondition;
         }
         $affectedRows = $this->conn->executeUpdate($sql, $data);
     }
     // only add to the cache if we already loaded data for the user
     if ($affectedRows > 0 && isset($this->cache[$user])) {
         if (!isset($this->cache[$user][$app])) {
             $this->cache[$user][$app] = array();
         }
         $this->cache[$user][$app][$key] = $value;
     }
     return $affectedRows > 0 ? true : false;
 }
开发者ID:droiter,项目名称:openwrt-on-android,代码行数:49,代码来源:preferences.php

示例2: copyTable

 protected function copyTable(Connection $fromDB, Connection $toDB, $table, InputInterface $input, OutputInterface $output)
 {
     /** @var $progress \Symfony\Component\Console\Helper\ProgressHelper */
     $progress = $this->getHelperSet()->get('progress');
     $query = 'SELECT COUNT(*) FROM ' . $table;
     $count = $fromDB->fetchColumn($query);
     $query = 'SELECT * FROM ' . $table;
     $statement = $fromDB->executeQuery($query);
     $progress->start($output, $count);
     $progress->setRedrawFrequency($count > 100 ? 5 : 1);
     while ($row = $statement->fetch()) {
         $progress->advance();
         if ($input->getArgument('type') === 'oci') {
             $data = $row;
         } else {
             $data = array();
             foreach ($row as $columnName => $value) {
                 $data[$toDB->quoteIdentifier($columnName)] = $value;
             }
         }
         $toDB->insert($table, $data);
     }
     $progress->finish();
 }
开发者ID:Romua1d,项目名称:core,代码行数:24,代码来源:converttype.php


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