本文整理汇总了PHP中Version::save_dbversion方法的典型用法代码示例。如果您正苦于以下问题:PHP Version::save_dbversion方法的具体用法?PHP Version::save_dbversion怎么用?PHP Version::save_dbversion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Version
的用法示例。
在下文中一共展示了Version::save_dbversion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSave_dbversion
public function testSave_dbversion()
{
Options::delete('db_version');
Version::save_dbversion();
$this->assertEquals(Version::DB_VERSION, Options::get('db_version'));
}
示例2: test_save_dbversion
function test_save_dbversion()
{
Options::delete('db_version');
Version::save_dbversion();
$this->assert_equal(Version::DB_VERSION, Options::get('db_version'));
}
示例3: upgrade_db
/**
* Upgrade the database when the database version stored is lower than the one in source
* @todo Make more db-independent
*/
public function upgrade_db()
{
if (Options::get('db_upgrading')) {
// quit with an error message.
$this->display_currently_upgrading();
}
// don't allow duplicate upgrades.
Options::set('db_upgrading', true);
// This database-specific code needs to be moved into the schema-specific functions
list($schema, $remainder) = explode(':', Config::get('db_connection')->connection_string);
switch ($schema) {
case 'sqlite':
$db_name = '';
break;
case 'mysql':
case 'pgsql':
$pairs = $this->parse_dsn($remainder);
$db_name = $pairs['dbname'];
break;
}
Cache::purge();
// get the current db version
$version = Options::get('db_version');
// do some pre-dbdelta ad-hoc hacky hack code
$this->upgrade_db_pre($version);
// run schema-specific upgrade scripts for before dbdelta
DB::upgrade_pre($version);
// Get the queries for this database and apply the changes to the structure
$queries = $this->get_create_table_queries($schema, Config::get('db_connection')->prefix, $db_name);
DB::dbdelta($queries);
// Apply data changes to the database based on version, call the db-specific upgrades, too.
$this->upgrade_db_post($version);
// run schema-specific upgrade scripts for after dbdelta
DB::upgrade_post($version);
Version::save_dbversion();
Options::delete('db_upgrading');
}
示例4: upgrade_db
/**
* Upgrade the database when the database version stored is lower than the one in source
* @todo Make more db-independent
*/
public function upgrade_db()
{
// This database-specific code needs to be moved into the schema-specific functions
list($schema, $remainder) = explode(':', Config::get('db_connection')->connection_string);
switch ($schema) {
case 'sqlite':
$db_name = '';
break;
case 'mysql':
list($host, $name) = explode(';', $remainder);
list($discard, $db_name) = explode('=', $name);
break;
case 'pgsql':
list($host, $name) = explode(' ', $remainder);
list($discard, $db_name) = explode('=', $name);
break;
}
// get the current db version
$version = Options::get('db_version');
// do some pre-dbdelta ad-hoc hacky hack code
$this->upgrade_db_pre($version);
// run schema-specific upgrade scripts for before dbdelta
DB::upgrade_pre($version);
// Get the queries for this database and apply the changes to the structure
$queries = $this->get_create_table_queries($schema, Config::get('db_connection')->prefix, $db_name);
DB::dbdelta($queries);
// Apply data changes to the database based on version, call the db-specific upgrades, too.
$this->upgrade_db_post($version);
// run schema-specific upgrade scripts for after dbdelta
DB::upgrade_post($version);
Version::save_dbversion();
}