本文整理汇总了PHP中Package::installDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::installDB方法的具体用法?PHP Package::installDB怎么用?PHP Package::installDB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::installDB方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: refresh_database_schema
public function refresh_database_schema()
{
if ($this->token->validate("refresh_database_schema")) {
$msg = '';
if ($this->post('refresh_global_schema')) {
// refresh concrete/config/db.xml and all installed blocks
$cnt = Loader::controller("/upgrade");
try {
$cnt->refresh_schema();
$msg .= t('Core database files and installed blocks refreshed.');
} catch (Exception $e) {
$this->set('error', $e);
}
}
if ($this->post('refresh_local_schema')) {
// refresh concrete/config/db.xml and all installed blocks
if (file_exists('config/' . FILENAME_LOCAL_DB)) {
try {
Package::installDB(DIR_BASE . '/config/' . FILENAME_LOCAL_DB);
$msg .= ' ' . t('Local database file refreshed.');
} catch (Exception $e) {
$this->set('error', $e);
}
}
}
$msg = trim($msg);
$this->set('message', $msg);
} else {
$this->set('error', array($this->token->getErrorMessage()));
}
}
示例2: prepare
public function prepare()
{
// we install the updated schema just for tables that matter
Package::installDB(dirname(__FILE__) . '/db/version_540.xml');
$db = Loader::db();
$db->Execute('alter table CollectionVersionBlockStyles drop primary key');
$db->Execute('alter table CollectionVersionBlockStyles add primary key (cID, bID, cvID, arHandle)');
}
示例3: upgrade
public function upgrade()
{
Package::installDB($this->getPackagePath() . '/' . FILENAME_PACKAGE_DB);
// now we refresh all blocks
$items = $this->getPackageItems();
if (is_array($items['block_types'])) {
foreach ($items['block_types'] as $item) {
$item->refresh();
}
}
}
示例4: add
public static function add($atHandle, $atName, $pkg = false) {
$pkgID = 0;
if (is_object($pkg)) {
$pkgID = $pkg->getPackageID();
}
$db = Loader::db();
$db->Execute('insert into AttributeTypes (atHandle, atName, pkgID) values (?, ?, ?)', array($atHandle, $atName, $pkgID));
$id = $db->Insert_ID();
$est = AttributeType::getByID($id);
$path = $est->getAttributeTypeFilePath(FILENAME_ATTRIBUTE_DB);
if ($path) {
Package::installDB($path);
}
return $est;
}
示例5: install_database
public function install_database()
{
$db = Loader::db();
$installDirectory = DIR_BASE_CORE . '/config';
try {
Database::ensureEncoding();
Package::installDB($installDirectory . '/db.xml');
} catch (Exception $e) {
throw new Exception(t('Unable to install database: %s', $db->ErrorMsg()));
}
}
示例6: prepare
public function prepare() {
$db = Loader::db();
Package::installDB(dirname(__FILE__) . '/db/version_5331.xml');
}
示例7: refresh_schema
public function refresh_schema()
{
if ($this->upgrade_db) {
$installDirectory = DIR_BASE_CORE . '/config';
$file = $installDirectory . '/db.xml';
if (!file_exists($file)) {
throw new Exception(t('Unable to locate database import file.'));
}
$err = Package::installDB($file);
// now we refresh the block schema
$btl = new BlockTypeList();
$btArray = $btl->getInstalledList();
foreach ($btArray as $bt) {
$bt->refresh();
}
$this->upgrade_db = false;
}
}
示例8: install
/**
* Installs the current block's DB xml file. If a block needs to do more than this, this should be overridden.
* <code>
* public function install($path) {
* $this->doMySpecialInstallMethod();
* $this->doSecondSpecialInstallMethod();
* parent::install($path);
* }
* </code>
*
* There are several different possible return values:
* Returns FALSE if $btTable is set but no db.xml file exists.
* Otherwise returns object with two properties: ->result (a boolean), and ->message (a string).
* If ->result is true, the installation was successful
* (although the db.xml file might only have one field declared which will cause C5 to have problems later on, so you you will want to check for that separately).
* If ->result is false, the installation failed and you can check ->message for the explanation
* (usually -- sometimes ->message will be blank, in which case there's either a malformed db.xml file or an "unknown database error").
* See concrete/models/block_types.php::doInstallBlockType() for usage example.
*
* @param string $path
* @return mixed boolean or object having ->result (boolean) and ->message (string) properties
*/
function install($path)
{
// passed path is the path to this block (try saying that ten times fast)
// create the necessary table
if (!$this->btTable) {
$r = new stdClass();
$r->result = true;
return $r;
}
$ret = Package::installDB($path . '/' . $this->dbFile);
return $ret;
}
示例9: prepare
public function prepare() {
// we install the updated schema just for tables that matter
Package::installDB(dirname(__FILE__) . '/db/version_542.xml');
}
示例10: install
/**
* Installs the current block's DB xml file. If a block needs to do more than this, this should be overridden.
* <code>
* public function install($path) {
* $this->doMySpecialInstallMethod();
* $this->doSecondSpecialInstallMethod();
* parent::install($path);
* }
* </code>
* @param string $path
* @return bool $didInstallCorrectly
*/
function install($path)
{
// passed path is the path to this block (try saying that ten times fast)
// create the necessary table
$ret = Package::installDB($path . '/' . $this->dbFile);
return $ret;
}
示例11: refreshDatabaseTables
protected function refreshDatabaseTables($tables)
{
$dbxml = simplexml_load_file(DIR_BASE_CORE . '/config/db.xml');
$output = new SimpleXMLElement("<schema></schema>");
$output->addAttribute('version', '0.3');
foreach ($dbxml->table as $t) {
$name = (string) $t['name'];
if (in_array($name, $tables)) {
$this->xmlAppend($output, $t);
}
}
$xml = $output->asXML();
if ($xml) {
$file = Loader::helper('file')->getTemporaryDirectory() . '/tmpupgrade_' . time() . '.xml';
@file_put_contents($file, $xml);
if (file_exists($file)) {
Package::installDB($file);
@unlink($file);
} else {
throw new Exception(t('Unable to create temporary db xml file: %s', $file));
}
}
}