本文整理汇总了PHP中OC\DB\Connection::prepare方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::prepare方法的具体用法?PHP Connection::prepare怎么用?PHP Connection::prepare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\DB\Connection
的用法示例。
在下文中一共展示了Connection::prepare方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param \OCP\IConfig $config
* @param \OC\DB\Connection $connection
*/
public function __construct($config, $connection)
{
$this->connection = $connection;
$this->config = $config;
$this->findStorageInCacheStatement = $this->connection->prepare('SELECT DISTINCT `storage` FROM `*PREFIX*filecache`' . ' WHERE `storage` in (?, ?)');
$this->renameStorageStatement = $this->connection->prepare('UPDATE `*PREFIX*storages`' . ' SET `id` = ?' . ' WHERE `id` = ?');
}
示例2: run
/**
* Fix mime types
*/
public function run()
{
if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
$this->emit('\\OC\\Repair', 'info', array('Not a mysql database -> nothing to no'));
return;
}
$tables = $this->getAllNonUTF8BinTables($this->connection);
foreach ($tables as $table) {
$query = $this->connection->prepare('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;');
$query->execute();
}
}
示例3: run
/**
* Fix mime types
*/
public function run(IOutput $output)
{
if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
$output->info('Not a mysql database -> nothing to no');
return;
}
$tables = $this->getAllNonUTF8BinTables($this->connection);
foreach ($tables as $table) {
$output->info("Change collation for {$table} ...");
$query = $this->connection->prepare('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;');
$query->execute();
}
}
示例4: getUsersForValue
/**
* Gets the users for a preference
* @param string $app
* @param string $key
* @param string $value
* @param int|null $limit
* @param int|null $offset
* @return array
*/
public function getUsersForValue($app, $key, $value, $limit = null, $offset = null)
{
$users = array();
$query = 'SELECT `userid` ' . ' FROM `*PREFIX*preferences` ' . ' WHERE `appid` = ? AND `configkey` = ? AND ';
if (\OC_Config::getValue('dbtype', 'sqlite') === 'oci') {
//FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison
$query .= ' to_char(`configvalue`)= ?';
} else {
$query .= ' `configvalue` = ?';
}
$stmt = $this->conn->prepare($query, $limit, $offset);
$stmt->execute(array($app, $key, $value));
while ($row = $stmt->fetch()) {
$users[] = $row['userid'];
}
return $users;
}
示例5: prepare
/**
* Prepare a SQL query
* @param string $query Query string
* @param int $limit
* @param int $offset
* @param bool $isManipulation
* @throws DatabaseException
* @return OC_DB_StatementWrapper prepared SQL query
*
* SQL query via Doctrine prepare(), needs to be execute()'d!
*/
public static function prepare($query, $limit = null, $offset = null, $isManipulation = null)
{
self::connect();
if ($isManipulation === null) {
//try to guess, so we return the number of rows on manipulations
$isManipulation = self::isManipulation($query);
}
// return the result
try {
$result = self::$connection->prepare($query, $limit, $offset);
} catch (\Doctrine\DBAL\DBALException $e) {
throw new \DatabaseException($e->getMessage(), $query);
}
// differentiate between query and manipulation
$result = new OC_DB_StatementWrapper($result, $isManipulation);
return $result;
}