本文整理汇总了PHP中xPDO::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDO::setOption方法的具体用法?PHP xPDO::setOption怎么用?PHP xPDO::setOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xPDO
的用法示例。
在下文中一共展示了xPDO::setOption方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConnection
/**
* Get an xPDO connection to the database.
*
* @param int $mode
* @return xPDO A copy of the xpdo object.
*/
public function getConnection($mode = 0)
{
if ($this->settings && empty($mode)) {
$mode = (int) $this->settings->get('installmode');
}
if (empty($mode)) {
$mode = modInstall::MODE_NEW;
}
if ($mode === modInstall::MODE_UPGRADE_REVO) {
$errors = array();
$this->xpdo = $this->_modx($errors);
} else {
if (!is_object($this->xpdo)) {
$options = array();
if ($this->settings->get('new_folder_permissions')) {
$options['new_folder_permissions'] = $this->settings->get('new_folder_permissions');
}
if ($this->settings->get('new_file_permissions')) {
$options['new_file_permissions'] = $this->settings->get('new_file_permissions');
}
$this->xpdo = $this->_connect($this->settings->get('database_dsn'), $this->settings->get('database_user'), $this->settings->get('database_password'), $this->settings->get('table_prefix'), $options);
if (!$this->xpdo instanceof xPDO) {
return $this->xpdo;
}
$this->xpdo->setOption('cache_path', MODX_CORE_PATH . 'cache/');
if ($mode === modInstall::MODE_UPGRADE_REVO_ADVANCED) {
if ($this->xpdo->connect()) {
$errors = array();
$this->xpdo = $this->_modx($errors);
} else {
return $this->lexicon('db_err_connect_upgrade');
}
}
}
}
if (is_object($this->xpdo) && $this->xpdo instanceof xPDO) {
$this->xpdo->setLogTarget(array('target' => 'FILE', 'options' => array('filename' => 'install.' . MODX_CONFIG_KEY . '.' . strftime('%Y-%m-%dT%H.%M.%S') . '.log')));
$this->xpdo->setLogLevel(xPDO::LOG_LEVEL_ERROR);
$this->xpdo->setPackage('modx', MODX_CORE_PATH . 'model/', $this->settings->get('table_prefix'));
}
return $this->xpdo;
}