本文整理汇总了PHP中xPDO::addPackage方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDO::addPackage方法的具体用法?PHP xPDO::addPackage怎么用?PHP xPDO::addPackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xPDO
的用法示例。
在下文中一共展示了xPDO::addPackage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: die
die('The default template id must be set. Check that $default_template_id is set and is an integer.');
}
// Include the xpdo and modx classes
include '../../xpdo/xpdo.class.php';
include '../../model/modx/modx.class.php';
// Instantiate a new modx object. MODx inherits from xpdo so we can use it
// like an xpdo object, but it has the extra functions needed for saving content.
// Thanks to Shaun McCormick for writing docs on this.
$modx = new modX();
$modx->initialize('web');
// Add the Quip package
$can_migrate_comments = $modx->addPackage('quip', '../../components/quip/model/', $modx->db->config['table_prefix']);
// Now instantiate a new xpdo object and add our wordpress package. This gives
// us the ability to make queries on the wordpress database as an xpdo object.
$wp = new xPDO('mysql:host=' . $wp_database_host . ';dbname=' . $wp_database_name . ';charset=' . $wp_database_charset, $wp_database_username, $wp_database_password);
$can_migrate_wp = $wp->addPackage('wordpress', '../', $wp_database_prefix);
if (!$can_migrate_wp) {
die('Wordpress Package could not be loaded.');
}
/**
* during migrations where you need to try, try and try again to get it right,
* it's easier to truncate the tables here instead of doing it manually.
* setting $empty_tables to true will delete data from the following tables.
*/
if ($empty_tables) {
if ($can_migrate_comments) {
$modx->db->query('TRUNCATE ' . $modx->getFullTableName('quip_comments'));
$modx->db->query('TRUNCATE ' . $modx->getFullTableName('quip_comments_closure'));
}
$modx->db->query('TRUNCATE ' . $modx->getFullTableName('site_content'));
$modx->db->query('TRUNCATE ' . $modx->getFullTableName('site_templates') . 'WHERE id != 1');
示例2: getXpdoInstanceAndAddPackage
public function getXpdoInstanceAndAddPackage($scriptProperties)
{
$modx =& $this->modx;
$prefix = isset($scriptProperties['prefix']) ? $scriptProperties['prefix'] : '';
$usecustomprefix = $modx->getOption('useCustomPrefix', $scriptProperties, '');
$usecustomprefix = empty($usecustomprefix) ? $modx->getOption('usecustomprefix', $scriptProperties, '') : $usecustomprefix;
$usecustomprefix = empty($usecustomprefix) ? $modx->getOption('use_custom_prefix', $scriptProperties, '') : $usecustomprefix;
if (empty($prefix)) {
$prefix = !empty($usecustomprefix) ? $prefix : null;
}
$packageName = $modx->getOption('packageName', $scriptProperties, '');
if (!empty($packageName)) {
$packagepath = $this->modx->getOption('core_path') . 'components/' . $packageName . '/';
$modelpath = $packagepath . 'model/';
$xpdo_name = $packageName . '_xpdo';
if (isset($this->modx->{$xpdo_name})) {
//create xpdo-instance for that package only once
$xpdo =& $this->modx->{$xpdo_name};
} elseif (file_exists($packagepath . 'config/config.inc.php')) {
include $packagepath . 'config/config.inc.php';
if (is_null($prefix) && isset($table_prefix)) {
$prefix = $table_prefix;
}
$charset = '';
if (!empty($database_connection_charset)) {
$charset = ';charset=' . $database_connection_charset;
}
$dsn = $database_type . ':host=' . $database_server . ';dbname=' . $dbase . $charset;
$xpdo = new xPDO($dsn, $database_user, $database_password);
//echo $o=($xpdo->connect()) ? 'Connected' : 'Not Connected';
$this->modx->{$xpdo_name} =& $xpdo;
} else {
$xpdo =& $this->modx;
}
$xpdo->addPackage($packageName, $modelpath, $prefix);
} else {
$xpdo =& $this->modx;
}
return $xpdo;
}
示例3: xPDO
print_msg(sprintf('<br/><strong>Ok:</strong> Using existing XML schema file:<br/><code>%s</code>', $xml_schema_file));
}
$xpdo = new xPDO("mysql:host={$database_server};dbname={$dbase}", $database_user, $database_password);
$xpdo->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$manager = $xpdo->getManager();
$generator = $manager->getGenerator();
// Use this to generate classes and maps from your schema
if ($regenerate_classes) {
print_msg('<br/>Attempting to remove/regenerate class files...');
delete_class_files($class_dir);
delete_class_files($mysql_class_dir);
}
print "<br/>Parsing schema {$xml_schema_file} <br/>";
$generator->parseSchema($xml_schema_file, $model_dir);
$generator->parseSchema($adjusted_core_path . "components/{$package_name}/model/schema/foxycart.mysql.schema.xml", $model_dir);
if (!$xpdo->addPackage('survey', $adjusted_core_path . 'components/survey/model/', 'survey_')) {
return 'Package Error.';
}
// Clear out Tables
print '<h3>Dropping Tables...</h3>';
//$xpdo->setLogLevel(xPDO::LOG_LEVEL_FATAL); // keep it quiet
$manager->removeObjectContainer('Survey');
$manager->removeObjectContainer('Question');
$manager->removeObjectContainer('Response');
$manager->removeObjectContainer('Data');
print '<code>Done.</code>';
/*
print '<h3>Removing Taxonomy and Term Records on modx_site_content Tables...</h3>';
//Removing Taxonomies
$taxonomies = $modx->getCollection('Taxonomy',array('class_key'=>'Taxonomy'));
if($taxonomies) {