本文整理汇总了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);
}
}