本文整理匯總了PHP中OCP\DB::getConnection方法的典型用法代碼示例。如果您正苦於以下問題:PHP DB::getConnection方法的具體用法?PHP DB::getConnection怎麽用?PHP DB::getConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OCP\DB
的用法示例。
在下文中一共展示了DB::getConnection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: reset
/**
* Reset the flag to true for all accounts
* @param OutputInterface $output
*/
protected function reset($output)
{
try {
\OCP\DB::beginTransaction();
$sql = "UPDATE *PREFIX*preferences\n SET configvalue = 1\n WHERE appid = 'user_set_password' AND configkey = 'show'";
$stmt = \OCP\DB::prepare($sql);
$rowCount = $stmt->execute();
\OCP\DB::commit();
$this->consoleDisplay(' flags have been resetted to "true".');
} catch (\Exception $e) {
// rollBack not implemented in \OCP\DB! (ownCloud 7.0.5)
$conn = \OCP\DB::getConnection();
$conn->rollBack();
$this->consoleDisplay('Fatal error: ' . $e->getMessage(), self::ERROR);
}
}
示例2: Init
/**
* Create a flag set to false for each existing account
* @param OutputInterface $output
*/
protected function Init($output)
{
try {
\OCP\DB::beginTransaction();
$sql = "INSERT INTO *PREFIX*preferences\n (SELECT uid, 'user_set_password', 'show', 0 FROM oc_users)\n ON duplicate key UPDATE configvalue = 0";
$stmt = \OCP\DB::prepare($sql);
$rowCount = $stmt->execute();
\OCP\DB::commit();
$this->consoleDisplay(' flags have been initialized to "false".');
} catch (\Exception $e) {
// rollBack not implemented in \OCP\DB! (ownCloud 7.0.5)
$conn = \OCP\DB::getConnection();
$conn->rollBack();
$this->consoleDisplay('Fatal error: ' . $e->getMessage(), self::ERROR);
}
}