本文整理汇总了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);
}
}
示例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;
}
示例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];
}
示例4: contains
public function contains($md5)
{
$query = 'SELECT * FROM blender WHERE md5 = "' . $md5 . '"';
$rs = $this->conn->fetchArray($query);
return $rs ? count($rs) > 0 : $rs;
}
示例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;
}