本文整理汇总了PHP中OC_DB::getDbStructure方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_DB::getDbStructure方法的具体用法?PHP OC_DB::getDbStructure怎么用?PHP OC_DB::getDbStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_DB
的用法示例。
在下文中一共展示了OC_DB::getDbStructure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doTestSchemaDumping
public function doTestSchemaDumping() {
$outfile = 'static://db_out.xml';
OC_DB::getDbStructure($outfile);
$content = file_get_contents($outfile);
$this->assertContains($this->table1, $content);
$this->assertContains($this->table2, $content);
}
示例2: export
/**
* exports a user, or owncloud instance
* @param string $uid user id of user to export if export type is user, defaults to current
* @param string $type type of export, defualts to user
* @param string $path path to zip output folder
* @return string on error, path to zip on success
*/
public static function export($uid = null, $type = 'user', $path = null)
{
$datadir = OC_Config::getValue('datadirectory');
// Validate export type
$types = array('user', 'instance', 'system', 'userfiles');
if (!in_array($type, $types)) {
OC_Log::write('migration', 'Invalid export type', OC_Log::ERROR);
return json_encode(array('success' => false));
}
self::$exporttype = $type;
// Userid?
if (self::$exporttype == 'user') {
// Check user exists
self::$uid = is_null($uid) ? OC_User::getUser() : $uid;
if (!OC_User::userExists(self::$uid)) {
return json_encode(array('success' => false));
}
}
// Calculate zipname
if (self::$exporttype == 'user') {
$zipname = 'oc_export_' . self::$uid . '_' . date("y-m-d_H-i-s") . '.zip';
} else {
$zipname = 'oc_export_' . self::$exporttype . '_' . date("y-m-d_H-i-s") . '.zip';
}
// Calculate path
if (self::$exporttype == 'user') {
self::$zippath = $datadir . '/' . self::$uid . '/' . $zipname;
} else {
if (!is_null($path)) {
// Validate custom path
if (!file_exists($path) || !is_writeable($path)) {
OC_Log::write('migration', 'Path supplied is invalid.', OC_Log::ERROR);
return json_encode(array('success' => false));
}
self::$zippath = $path . $zipname;
} else {
// Default path
self::$zippath = get_temp_dir() . '/' . $zipname;
}
}
// Create the zip object
if (!self::createZip()) {
return json_encode(array('success' => false));
}
// Do the export
self::findProviders();
$exportdata = array();
switch (self::$exporttype) {
case 'user':
// Connect to the db
self::$dbpath = $datadir . '/' . self::$uid . '/migration.db';
if (!self::connectDB()) {
return json_encode(array('success' => false));
}
self::$content = new OC_Migration_Content(self::$zip, self::$migration_database);
// Export the app info
$exportdata = self::exportAppData();
// Add the data dir to the zip
self::$content->addDir(OC_User::getHome(self::$uid), true, '/');
break;
case 'instance':
self::$content = new OC_Migration_Content(self::$zip);
// Creates a zip that is compatable with the import function
$dbfile = tempnam(get_temp_dir(), "owncloud_export_data_");
OC_DB::getDbStructure($dbfile, 'MDB2_SCHEMA_DUMP_ALL');
// Now add in *dbname* and *dbprefix*
$dbexport = file_get_contents($dbfile);
$dbnamestring = "<database>\n\n <name>" . OC_Config::getValue("dbname", "owncloud");
$dbtableprefixstring = "<table>\n\n <name>" . OC_Config::getValue("dbtableprefix", "oc_");
$dbexport = str_replace($dbnamestring, "<database>\n\n <name>*dbname*", $dbexport);
$dbexport = str_replace($dbtableprefixstring, "<table>\n\n <name>*dbprefix*", $dbexport);
// Add the export to the zip
self::$content->addFromString($dbexport, "dbexport.xml");
// Add user data
foreach (OC_User::getUsers() as $user) {
self::$content->addDir(OC_User::getHome($user), true, "/userdata/");
}
break;
case 'userfiles':
self::$content = new OC_Migration_Content(self::$zip);
// Creates a zip with all of the users files
foreach (OC_User::getUsers() as $user) {
self::$content->addDir(OC_User::getHome($user), true, "/");
}
break;
case 'system':
self::$content = new OC_Migration_Content(self::$zip);
// Creates a zip with the owncloud system files
self::$content->addDir(OC::$SERVERROOT . '/', false, '/');
foreach (array(".git", "3rdparty", "apps", "core", "files", "l10n", "lib", "ocs", "search", "settings", "tests") as $dir) {
self::$content->addDir(OC::$SERVERROOT . '/' . $dir, true, "/");
}
break;
//.........这里部分代码省略.........