本文整理汇总了PHP中ConnectionManager::getDataSouce方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionManager::getDataSouce方法的具体用法?PHP ConnectionManager::getDataSouce怎么用?PHP ConnectionManager::getDataSouce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionManager
的用法示例。
在下文中一共展示了ConnectionManager::getDataSouce方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: first_import
/**
* firstImport method
*
* accepts an xml dump (generated from the nodes controller admin_export function)
* and contents with the file contents.
*
* @param mixed $xml
* @return void
* @access public
*/
function first_import($xml, $options = array(), $thisUser = false)
{
$deleteFirst = true;
$addingTranslation = false;
extract($options);
uses('Xml');
$xml = new Xml($xml);
$xml = Set::reverse($xml);
$meta = Set::extract($xml, '/Contents/Meta');
$nodes = Set::extract($xml, '/Contents/Node');
$nodes = $nodes[0];
$ids = Set::extract($nodes, '/Node/id');
set_time_limit(count($ids) * 2);
unset($this->Revision->validate['content']);
if (Configure::read('Languages.default') != $meta[0]['Meta']['lang']) {
$addingTranslation = true;
if ($this->find('count') > 0) {
$deleteFirst = false;
}
}
$db =& ConnectionManager::getDataSouce($this->useDbConfig);
$db->begin($this);
if ($deleteFirst) {
$db =& ConnectionManager::getDatasource('default');
$db->query('truncate nodes');
$db->query('truncate changes');
$db->query('truncate revisions');
}
foreach ($nodes['Node'] as $i => $row) {
extract($row);
if ($addingTranslation && $Revision['lang'] == Configure::read('Languages.default')) {
continue;
}
$parent_id = empty($parent_id) ? null : $parent_id;
if (!$addingTranslation) {
$depth = empty($depth) ? 0 : $depth;
$show_in_toc = empty($show_in_toc) ? 0 : 1;
$status = 1;
$sequence = null;
$toSave = compact('id', 'parent_id', 'depth', 'status', 'show_in_toc');
if ($i == 0) {
$toSave['lft'] = 1;
$toSave['rght'] = 2;
} else {
$toSave['lft'] = $parent_id;
$rght = $this->field('id', array('parent_id' => $id));
$toSave['rght'] = empty($rght) ? 0 : $rght;
}
$this->create();
$this->id = false;
if (!$this->save(array('Node' => $toSave), false)) {
$db->rallback($this);
return false;
}
}
$toSave = $Revision;
$toSave['reason'] = empty($toSave['reason']) || is_array($toSave['reason']) ? "" : $toSave['reason'];
$toSave['content'] = empty($toSave['content']) || is_array($toSave['content']) ? "" : $toSave['content'];
$toSave['node_id'] = $id;
$toSave['under_node_id'] = $parent_id;
$toSave['status'] = 'current';
if ($thisUser) {
$toSave['user_id'] = $thisUser;
}
$this->Revision->create();
if (!$this->Revision->save(array('Revision' => $toSave), false)) {
$db->rallback($this);
return false;
}
}
$db->commit($this);
return true;
}