當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Doctrine_Migration::setTableName方法代碼示例

本文整理匯總了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;
 }
開發者ID:podstawski,項目名稱:papu,代碼行數:31,代碼來源:index.php


注:本文中的Doctrine_Migration::setTableName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。