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


PHP Connection::fetchArray方法代码示例

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


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

示例1: controlOptimisticConcurrency

 /**
  * @param Contract $streamContract
  * @param Identifier $streamId
  * @param $expectedStreamRevision
  * @throws \EventCentric\Persistence\OptimisticConcurrencyFailed
  */
 protected function controlOptimisticConcurrency(Contract $streamContract, Identifier $streamId, $expectedStreamRevision)
 {
     $result = $this->connection->fetchArray(MaxStreamRevision::from(self::TABLE_NAME), ['streamContract' => $streamContract, 'streamId' => $streamId]);
     $actualStreamRevision = (int) $result[0];
     if ($actualStreamRevision != $expectedStreamRevision) {
         throw OptimisticConcurrencyFailed::revisionDoesNotMatch($expectedStreamRevision, $actualStreamRevision);
     }
 }
开发者ID:dpsarrou,项目名称:EventCentric.Core,代码行数:14,代码来源:MySQLPersistence.php

示例2: prepareDatabase

    /**
     * Makes sure database is created and ready to use.
     *
     * @param Fiddle $fiddle
     * @return string
     */
    protected function prepareDatabase(Fiddle $fiddle)
    {
        $directory = $this->getDirectory($fiddle);
        $fiddleEscaped = $this->db->quote($fiddle->getId(), \PDO::PARAM_STR);
        $fiddleId = $this->db->quoteIdentifier($fiddle->getId());
        if (!$this->debug && file_exists($directory . '/home/sandbox/propel.yml')) {
            return false;
        }
        $dbName = 'fiddle_' . $fiddle->getId();
        $userName = $fiddle->getId();
        $password = substr(md5(microtime() * 10000 + mt_rand()), 0, 14);
        $dbNameIdentifier = $this->db->quoteIdentifier($dbName);
        //create new db credentials
        $row = $this->db->fetchArray("SHOW DATABASES LIKE ?", [$dbName]);
        if (false === $row) {
            // database does not exist yet
            $this->db->executeQuery(sprintf("CREATE DATABASE %s", $dbNameIdentifier));
        }
        $user = $this->db->fetchArray("SELECT User FROM mysql.user WHERE User = ?", [$fiddle->getId()]);
        // we don't save the password in our database so we have to remove the user first
        if ($user) {
            $this->db->executeQuery(sprintf("DROP USER %s@'localhost'", $fiddleEscaped));
        }
        $this->db->executeQuery(sprintf("CREATE USER %s@'localhost' IDENTIFIED BY %s", $fiddleEscaped, $this->db->quote($password, \PDO::PARAM_STR)));
        $this->needConfigConvertCall = true;
        $this->db->executeQuery(sprintf("GRANT USAGE, ALTER, CREATE, DELETE, DROP, INDEX, INSERT, SELECT, UPDATE ON %s.* TO %s@'localhost'", $dbNameIdentifier, $fiddleEscaped));
        $propelConfig = <<<EOF
propel:
  database:
      connections:
          default:
              adapter: mysql
              classname: Propel\\Runtime\\Connection\\DebugPDO
              dsn: mysql:host=127.0.0.1;dbname={$dbName}
              user: {$userName}
              password: {$password}
              attributes:
  runtime:
      log:
          defaultLogger:
              type: stream
              path: ./propel_log.txt
              level: 100
      defaultConnection: default
      connections:
          - default
  generator:
      defaultConnection: default
      connections:
          - default
EOF;
        file_put_contents($directory . '/home/sandbox/propel.yml', $propelConfig);
        return $propelConfig;
    }
开发者ID:mehulsbhatt,项目名称:sandbox,代码行数:60,代码来源:Executor.php

示例3: getLastWeekCommonReviewsCount

 /**
  * All my reviews in common with my followers' reviews of the last week
  * @param $userId
  *
  * @return int
  */
 public function getLastWeekCommonReviewsCount($userId)
 {
     $followerIds = $this->userRepository->getFollowersIds($userId);
     $sql = 'SELECT COUNT(*) as counter
         FROM (
             SELECT reviews.id, reviews.restaurant_id
             FROM reviews
             WHERE reviews.user_id = ?) my_reviews
         INNER JOIN (
             SELECT reviews.id, reviews.restaurant_id
             FROM reviews
             WHERE reviews.user_id IN (?)
             AND reviews.created > DATE_SUB(NOW(), INTERVAL 1 WEEK)) follower_reviews
         ON my_reviews.restaurant_id = follower_reviews.restaurant_id';
     $result = $this->connection->fetchArray($sql, array($userId, $followerIds), array(\PDO::PARAM_INT, Connection::PARAM_INT_ARRAY));
     return (int) $result[0];
 }
开发者ID:oriodesign,项目名称:tastd-backend-demo,代码行数:23,代码来源:ScoreManager.php

示例4: contains

 public function contains($md5)
 {
     $query = 'SELECT * FROM blender WHERE md5 = "' . $md5 . '"';
     $rs = $this->conn->fetchArray($query);
     return $rs ? count($rs) > 0 : $rs;
 }
开发者ID:nlegoff,项目名称:Blender,代码行数:6,代码来源:Database.php

示例5: getAllMyIsamTables

 /**
  * @param \Doctrine\DBAL\Connection $connection
  * @return string[]
  */
 private function getAllMyIsamTables($connection)
 {
     $dbName = \OC::$server->getConfig()->getSystemValue("dbname");
     $result = $connection->fetchArray("SELECT table_name FROM information_schema.tables WHERE table_schema = ? AND engine = 'MyISAM' AND TABLE_NAME LIKE \"*PREFIX*%\"", array($dbName));
     return $result;
 }
开发者ID:mnefedov,项目名称:core,代码行数:10,代码来源:innodb.php


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