本文整理匯總了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;
}