本文整理汇总了PHP中Factory::db方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::db方法的具体用法?PHP Factory::db怎么用?PHP Factory::db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory::db方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 构造方法
* @param string $dbsource
*/
public function __construct($dbsource = null)
{
// 模型初始化
$this->_initialize();
if (is_null($dbsource)) {
$this->db = Factory::db($this->setting);
} else {
$this->db = Factory::db($dbsource);
}
$this->database = $this->db->get_database();
// 获取数据库名
$this->prefix = $this->db->get_prefix();
// 获取表前缀
$this->table_name = $this->prefix . $this->table_name;
// 字段检查
if ($this->auto_check_fields && $this->table_name != $this->prefix) {
$this->_check_table_info();
}
}
示例2: ini_set
* CHARACTER SET
************************************************************************/
ini_set('default_charset', 'UTF-8');
if (extension_loaded('mbstring')) {
mb_internal_encoding(CHARSET);
}
/************************************************************************
* CONNECT TO DATABASE(S)
************************************************************************/
if (defined('DB_NAME')) {
$db =& Factory::db(array('dsn' => DB_DSN, 'file' => DB_FILE, 'host' => DB_HOST, 'user' => DB_USER, 'pass' => DB_PASS, 'name' => DB_NAME));
Registry::set('pronto:db:main', $db);
} else {
require_once DIR_FS_APP . DS . 'config' . DS . 'databases.php';
foreach ($DATABASES as $key => $dbcfg) {
$db =& Factory::db($dbcfg);
Registry::set('pronto:db:' . $key, $db);
}
// we leave $db set for scripts that expect it
unset($key, $dbcfg);
}
// TODO: this should be unset, left for back-compat for now...
//unset($db);
/************************************************************************
* INTERNATIONALIZATION
************************************************************************/
$i18n = new I18N();
$i18n->autoset_language('en');
define('LANG', $i18n->get_language());
Registry::set('pronto:i18n', $i18n);
unset($i18n);
示例3: public_repair
/**
* 数据库修复、优化
*/
public function public_repair()
{
$tables = isset($_POST['tables']) ? $_POST['tables'] : trim($_GET['tables']);
$operation = trim($_GET['operation']);
$pdo_name = trim($_GET['pdo_name']);
$this->db = Factory::db($pdo_name);
$tables = is_array($tables) ? implode(',', $tables) : $tables;
if ($tables && in_array($operation, array('repair', 'optimize'))) {
$this->db->query("{$operation} TABLE {$tables}");
showmessage(L('operation_success'), '?app=admin&controller=database&action=export&pdoname=' . $pdo_name);
} elseif ($tables && $operation == 'showcreat') {
$structure = $this->db->query("SHOW CREATE TABLE {$tables}");
$structure = $structure[0]['Create Table'];
$show_header = true;
include $this->view('database_structure');
} else {
showmessage(L('select_tbl'), '?app=admin&controller=database&action=export&pdoname=' . $pdo_name);
}
}