本文整理汇总了PHP中MyDB::create方法的典型用法代码示例。如果您正苦于以下问题:PHP MyDB::create方法的具体用法?PHP MyDB::create怎么用?PHP MyDB::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyDB
的用法示例。
在下文中一共展示了MyDB::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
try {
$dbparams = ezcTestSettings::getInstance()->db->dsn;
MyDB::setParams($dbparams);
$this->db = MyDB::create();
} catch (Exception $e) {
$this->markTestSkipped();
}
}
示例2: convert
function convert()
{
global $tmp_path, $db_filename, $inpx_input;
$db = new MyDB($tmp_path . $db_filename);
if (!$db) {
die($db->lastErrorMsg());
}
$db->create();
// get the absolute path to $file
//$path = pathinfo(realpath($file), PATHINFO_DIRNAME);
$zip = new ZipArchive();
$res = $zip->open($inpx_input);
if ($res === TRUE) {
// extract it to the path we determined above
$zip->extractTo($tmp_path);
$zip->close();
echo "{$file} extracted to {$tmp_path}\n";
} else {
echo "Doh! I couldn't open {$inpx_input}\n";
}
$sep = chr(0x4);
foreach (glob($tmp_path . '*.inp') as $file) {
echo $file . "\n";
$records = explode("\n", file_get_contents($file));
foreach ($records as $rec) {
$array = explode($sep, $rec);
$authors_ids = array();
$authors = explode(':', $array[0]);
foreach ($authors as $author) {
if (!empty($author)) {
$author = trim(str_replace(',', ' ', $author), " -\t\r!@#\$%^&*()_=+|");
$author_id = $db->addAuthor($author);
//echo "$author_id -> $author\n";
if ($author_id) {
$authors_ids[] = $author_id;
}
}
}
$genres_ids = array();
$genres = explode(':', $array[1]);
foreach ($genres as $genre) {
if (!empty($genre)) {
$genre_id = $db->addGenre($genre);
//echo "$genre_id -> $genre\n";
if ($genre_id) {
$genres_ids[] = $genre_id;
}
}
}
$title = trim($array[2], " \t");
$title_id = $db->addTitle($title);
//echo "$title_id -> $title\n";
$file_name = trim($array[5], " \t");
$file_size = trim($array[6], " \t");
$file_ext = trim($array[9], " \t");
$date_add = trim($array[10], " \t");
$lang = trim($array[11], "' \t");
//echo "$file_name $file_ext\n";
$db->addFile($authors_ids, $genres_ids, $title_id, $file_name, $file_ext, $file_size, $lang, $date_add);
}
}
$db->close();
rename($tmp_path . $db_filename, './' . $db_filename);
// TODO: cleanup temporary directory
exit;
}