本文整理汇总了PHP中OC_DB::tableExists方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_DB::tableExists方法的具体用法?PHP OC_DB::tableExists怎么用?PHP OC_DB::tableExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_DB
的用法示例。
在下文中一共展示了OC_DB::tableExists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dropTableEncryption
public function dropTableEncryption()
{
$tableName = $this->tableName;
if (!\OC_DB::tableExists($tableName)) {
return;
}
$sql = "select `uid`, max(`recovery_enabled`) as `recovery_enabled`, min(`migration_status`) as `migration_status` from `*PREFIX*{$tableName}` group by `uid`";
$query = \OCP\DB::prepare($sql);
$result = $query->execute(array())->fetchAll();
foreach ($result as $row) {
\OC_Preferences::setValue($row['uid'], 'files_encryption', 'recovery_enabled', $row['recovery_enabled']);
\OC_Preferences::setValue($row['uid'], 'files_encryption', 'migration_status', $row['migration_status']);
}
\OC_DB::dropTable($tableName);
}
示例2: run
/**
* Fix duplicate entries in oc_lucene_status
*
* search_lucene prior to v0.5.0 did not have a primary key on the lucene_status table. Newer versions do, which
* causes the migration check to fail because it tries to insert duplicate rows into the new schema.
*
* FIXME Currently, apps don't have a way of repairing anything before the migration check:
* @link https://github.com/owncloud/core/issues/10980
*
* As a result this repair step needs to live in the core repo, although it belongs into search_lucene:
* @link https://github.com/owncloud/core/issues/10205#issuecomment-54957557
*
* It will completely remove any rows that make a file id have more than one status:
* fileid | status fileid | status
* --------+-------- will become --------+--------
* 2 | E 3 | E
* 2 | I
* 3 | E
*
* search_lucene will then reindex the fileids without a status when the next indexing job is executed
*/
public function run()
{
if (\OC_DB::tableExists('lucene_status')) {
$this->emit('\\OC\\Repair', 'info', array('removing duplicate entries from lucene_status'));
$connection = \OC_DB::getConnection();
$query = $connection->prepare('
DELETE FROM `*PREFIX*lucene_status`
WHERE `fileid` IN (
SELECT `fileid`
FROM (
SELECT `fileid`
FROM `*PREFIX*lucene_status`
GROUP BY `fileid`
HAVING count(`fileid`) > 1
) AS `mysqlerr1093hack`
)');
$query->execute();
} else {
$this->emit('\\OC\\Repair', 'info', array('lucene_status table does not exist -> nothing to do'));
}
}
示例3: assertTableNotExist
/**
* @param string $table
*/
public function assertTableNotExist($table)
{
$platform = \OC_DB::getConnection()->getDatabasePlatform();
if ($platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
// sqlite removes the tables after closing the DB
$this->assertTrue(true);
} else {
$this->assertFalse(OC_DB::tableExists($table), 'Table ' . $table . ' exists.');
}
}
示例4: assertTableNotExist
/**
* @param string $table
*/
public function assertTableNotExist($table)
{
$type = OC_Config::getValue("dbtype", "sqlite");
if ($type == 'sqlite' || $type == 'sqlite3') {
// sqlite removes the tables after closing the DB
$this->assertTrue(true);
} else {
$this->assertFalse(OC_DB::tableExists($table), 'Table ' . $table . ' exists.');
}
}