本文整理匯總了PHP中Doctrine_Migration::setTableName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Doctrine_Migration::setTableName方法的具體用法?PHP Doctrine_Migration::setTableName怎麽用?PHP Doctrine_Migration::setTableName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine_Migration
的用法示例。
在下文中一共展示了Doctrine_Migration::setTableName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: PDO
}
$db = new PDO($dsn[0], $user, $pass);
$conn = Doctrine_Manager::connection($db);
$dbtable = $conn->fetchOne("SELECT schema_name FROM information_schema.schemata WHERE schema_name='" . $dbname . "'");
if (!$dbtable) {
$sql = "CREATE DATABASE `" . $dbname . "` CHARACTER SET utf8;\n CREATE USER '" . $config['db.user'] . "'@'localhost' IDENTIFIED BY '" . $config['db.pass'] . "';\n GRANT ALL PRIVILEGES ON " . $dbname . ".* TO '" . $config['db.user'] . "'@'%' WITH GRANT OPTION;\n ";
$db->exec($sql);
}
$conn->close();
$db = new PDO($config['db.dsn'], $config['db.user'], $config['db.pass']);
$conn = Doctrine_Manager::connection($db);
if (isset($google_user)) {
echo 'user: ' . $google_user->getNickname() . '<br>';
}
$migration = new Doctrine_Migration(__DIR__ . '/classes', $conn);
$migration->setTableName('doctrine_migration_version');
if (isset($_REQUEST['ver']) && (!isset($google_user) || $google_user->getNickname() == 'piotr.podstawski@gammanet.pl')) {
$version = 0 + intval($_REQUEST['ver']);
} else {
$classesKeys = array_keys($migration->getMigrationClasses());
$version = 0 + array_pop($classesKeys);
}
if (isset($_SERVER['HTTP_HOST'])) {
echo '<h1>';
}
if ($migration->getCurrentVersion() == $version) {
echo 'Database at version ' . $version . PHP_EOL;
} else {
$migration->migrate($version);
echo 'Migrated succesfully to version ' . $migration->getCurrentVersion() . PHP_EOL;
}