本文整理汇总了PHP中Config::database方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::database方法的具体用法?PHP Config::database怎么用?PHP Config::database使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::database方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fieldToForm
/**
* 渲染表单主函数
* @param $field 字段
* @param $type 类型
* @param int $parent 父级 //对内容无用
* @param int $catid 栏目ID
* @param string $action 行为
* @param bool $id 内容的ID
*/
public function fieldToForm($field, $type, $parent = 0, $catid = 0, $action = 'add', $id = false)
{
$field = model()->stripslashes($field);
if ($action == 'edit') {
if ($type == 'category' || $type == 'page') {
$category = model('category')->where('cid', $catid)->getOne('catetable,catid');
$cid = $catid;
$catid = $category['catid'];
//转存cid
$catetable = $category['catetable'];
$content = model('category')->leftJoin($catetable, $catetable . '.id', 'category.catid')->where(Config::database('table_pre') . 'category.catid', $catid)->where(Config::database('table_pre') . 'category.cid', $cid)->getOne();
$this->content = model()->stripslashes($content);
unset($content);
} elseif ($type == 'content') {
$category = model('category')->where('cid', $catid)->getOne('contable,catid,show_view');
//var_dump($category);
$contable = $category['contable'];
$content = model($contable)->where('id', $id)->getOne();
if (empty($content)) {
$content['show_view'] = $category['show_view'];
}
$this->content = model()->stripslashes($content);
$this->content['show_view'] = $this->content['template'];
unset($this->content['template']);
}
}
//var_dump($field);
$form = '<table class="control-group"><tbody>';
if ($type == 'category' || $type == 'page') {
$form .= $this->select_category($parent);
}
foreach ($field as $ff) {
$ff = model('model_field')->parseSetting($ff);
if ($ff['formtype'] == 'text') {
$form .= $this->text($ff);
} elseif ($ff['formtype'] == 'textarea') {
$form .= $this->textarea($ff);
} elseif ($ff['formtype'] == 'title') {
$form .= $this->text($ff);
} elseif ($ff['formtype'] == 'editor') {
$form .= $this->editor($ff);
} elseif ($ff['formtype'] == 'picture') {
$form .= $this->picture($ff);
} elseif ($ff['formtype'] == 'pictures') {
$form .= $this->pictures($ff);
} elseif ($ff['formtype'] == 'file') {
$form .= $this->file($ff);
} elseif ($ff['formtype'] == 'files') {
$form .= $this->files($ff);
} elseif ($ff['formtype'] == 'date') {
$form .= $this->date($ff);
} elseif ($ff['formtype'] == 'areaSelect') {
$form .= $this->areaSelect($ff);
} else {
echo $ff['formtype'] . '不存在!';
}
}
$form .= $this->template($type, $catid);
echo $form .= '</table>';
}
示例2: get_instance
public static function get_instance()
{
if (self::$instance === NULL) {
self::$instance = new PDO('mysql:host=' . Config::database_server() . ';dbname=' . Config::database(), Config::database_username(), Config::database_password(), array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8, character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'"));
self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
self::$instance->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1);
}
return self::$instance;
}
示例3: init
public static function init()
{
if (!isset(self::$bInit)) {
$data = parse_ini_file(BASE_DIR . '/admin/configuration.ini', true);
self::$database = (object) $data['database'];
self::$settings = (object) $data['settings'];
self::$bInit = 'y';
}
}
示例4: connect
function connect()
{
$mysqli = mysqli_connect(Config::database('host') . ':' . Config::database('port'), Config::database('user'), Config::database('pass'), Config::database('name'));
if ($mysqli->connect_error) {
Debug::add('连接数据库失败:<font color=red>' . $mysqli->connect_error . '</font>');
exit('连接数据库失败:<font color=red>' . $mysqli->connect_error . '</font>');
} else {
$this->mysqli = $mysqli;
$this->exec('set names ' . Config::database('charset'));
return true;
}
}
示例5: load
static function load($config = array())
{
self::$config = $config;
self::$mode = $config['mode'];
self::$appsDir = $config['appsDir'];
self::$pluginsDir = $config['pluginsDir'];
self::$helpersDir = $config['helpersDir'];
self::$mainApp = $config['mainApp'];
self::$disabledApps = $config['disabledApps'];
self::$database = $config['database'];
self::init();
}
示例6: __construct
public function __construct($connection = 'default')
{
$config = Config::database();
$this->config = $config[$connection];
$driverNamespace = 'Drivers\\Database\\' . ucwords($this->config['driver']);
if (isset($this->config['pdo'])) {
if ($this->config['pdo']) {
$driverNamespace = 'Drivers\\Database\\PanadaPDO';
}
}
$this->driver = new $driverNamespace($this->config, $connection);
}
示例7: connect
function connect()
{
$con = @mysql_connect(Config::database('host') . ':' . Config::database('port'), Config::database('user'), Config::database('pass'));
if ($con) {
$r = mysql_select_db(Config::database('name'), $con) or Debug::add('连接数据库失败:<font color=red>' . mysql_error() . '</font>');
if ($r === true) {
$this->con = $con;
$this->exec('set names ' . Config::database('charset'));
return true;
}
} else {
Debug::add('连接Mysql服务器失败:,' . mysql_error());
}
return false;
}
示例8: connect
public function connect()
{
try {
$this->db = new pdo(config::database('DSN'), Config::database('user'), Config::database('pass'));
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
Debug::add('<font color="red">' . $e->getMessage() . '</font>');
}
if (!$this->db) {
return false;
} else {
$this->exec('set names ' . Config::database('charset'));
return true;
}
}
示例9: initialize
public function initialize()
{
Config::database();
//加载数据库配置
Loader::func('gouwanmei');
//引入全局函数
Config::set(array('cache' => 1), 'database');
if (!isset($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = '';
}
//var_dump($_SERVER);
$this->cacheKey = $_SERVER['REQUEST_URI'];
//获取站点配置
$setting = model('website')->where('siteid', 1)->getOne();
$this->setting = $setting;
$data['SEO'] = array();
$data['SEO']['title'] = $setting['title'];
$data['SEO']['keywords'] = $setting['keywords'];
$data['SEO']['description'] = $setting['description'];
$template = $setting['template'];
//站点配置中的前台模板
$data['website'] = $setting;
$data['page'] = isset($_GET['page']) ? $_GET['page'] : 1;
$data['user'] = Module('member')->isLogin($data['website']['membertokentype']);
//用户登录状态
$this->assign($data);
unset($setting);
Config::template();
//载入模板配置,防止将所有的配置替换
//==配置模板风格和静态缓存生存时间
//==配置模板风格和静态缓存生存时间
Config::set(array('view_name' => $template, 'template_parse' => 'template_parse', 'view_cache' => Config::cms('view_cache'), 'leftDelim' => Config::cms('tpl_leftDelim'), 'rightDelim' => Config::cms('tpl_rightDelim'), 'img_path' => Config::cms('img_path'), 'js_path' => Config::cms('js_path'), 'css_path' => Config::cms('css_path')), 'template');
//如果使用手机进入则会用mobile模板
if (isset($_SERVER['HTTP_USER_AGENT'])) {
if (preg_match('/mobile/i', $_SERVER['HTTP_USER_AGENT'])) {
Config::set(array('view_name' => 'mobile'), 'template');
}
}
Config::set(array('debug' => Config::cms('debug')), 'config');
}
示例10: desc
protected function desc($table_name)
{
return $this->execute('SHOW TABLES FROM `' . Config::database()->schema . '` LIKE \'' . $table_name . '\';')->fetchAll();
// return $this->execute('DESCRIBE `' . $table_name . '`;')->fetchAll();
}
示例11: getConfigParams
public function getConfigParams()
{
//$doctype_str = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
$doctype_str = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
self::$doctype = $doctype_str;
$godaddy_analytics_str = "<!--GODADDY ANALYTICS:--><script type=\"text/javascript\">\nvar gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");\ndocument.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));\n</script>\n<script type=\"text/javascript\">\ntry {\nvar pageTracker = _gat._getTracker(\"UA-15905158-1\");\npageTracker._trackPageview();\n} catch(err) {}\n</script>\n<script type=\"text/JavaScript\">var TFN='';var TFA='';var TFI='0';var TFL='0';var tf_RetServer=\"rt.trafficfacts.com\";\nvar tf_SiteId=\"14120g9493f85cbde65e99dd8c83e9c3f3473b29529d1fh10\";\nvar tf_ScrServer=document.location.protocol+\"//rt.trafficfacts.com/tf.php?k=14120g9493f85cbde65e99dd8c83e9c3f3473b29529d1fh10;c=s;v=5\";\ndocument.write(unescape('%3Cscript type=\"text/JavaScript\" src=\"'+tf_ScrServer+'\">%3C/script>'));</script>\n<noscript>\n<img src=\"http://rt.trafficfacts.com/ns.php?k=14120g9493f85cbde65e99dd8c83e9c3f3473b29529d1fh10\" height=\"1\" width=\"1\" alt=\"\"/>\n</noscript>";
$google_analytics_str = "<!--GOOGLE ANALYTICS:--><script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', 'UA-15905158-1']);\n _gaq.push(['_trackPageview']);\n\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n</script>";
self::$docroot = $_SERVER['DOCUMENT_ROOT'];
if (self::$server_name == 'twextra') {
self::$godaddy_analytics = $godaddy_analytics_str;
self::$google_analytics = '';
self::$hostname = "http://twextra.com";
//self::$cookie_name = "tw_tok";
self::$cookie_name = "tw_user_id";
self::$hostdb = '173.201.185.107';
self::$database = 'twextra';
self::$userdb = 'twextra';
self::$pwdb = 'Spearmint1';
self::$linkedin_access = 'U6zyYyGUwE5o0zvIkMnGosw2WpQusl-Pa4JNQyIy9IDdsDLKdp2by6qzwFM7H6Rv';
//linkedin-twextra
self::$linkedin_secret = 'GB-ssm8NUpUVD2h1X2dNxv2eESi8Tgc57hxciklT8-KsSPwNC9KcbOP1drSHSNUL';
//linkedin-twextra
self::$consumer_key = 'OIWt7zoGUChqHkELTyYx8g';
//twitter-twextra
self::$consumer_secret = 'oqLgz87EFUCNZYxNr7yEeZqHwTTPwv4CcwWS2K7YIg';
//twitter-twextra
self::$oauth_callback = self::$hostname . "/twitter/page2.php";
//twitter-twextra
self::$fb_app_id = '144934438868111';
} else {
if (self::$server_name == 'twetest') {
self::$godaddy_analytics = '';
self::$google_analytics = '';
self::$hostname = "http://twetest.com";
//self::$cookie_name = "tw_tok";
self::$cookie_name = "tw_user_id";
self::$hostdb = '173.201.217.33';
self::$database = 'twetest';
self::$userdb = 'twetest';
self::$pwdb = 'Spearmint1';
self::$linkedin_access = 'YMKaHlPF6xv8YTMs_FftnoC1tq_0Fgoz9Y8me0PvcR1Sm9WxzuPI18hZr2yP3fFq';
//linkedin-twetest
self::$linkedin_secret = 'PuKdmBOQFdR1vibAe0LX3yRkKhu-NWlZaqC3EwnsiiMw1OL0EZ_J_rmh5PjzHXfg';
//linkedin-twetest
self::$consumer_key = 'JBRzgN0LeUJFzCo2K1koGw';
//twitter-twetest
self::$consumer_secret = '1DuqRvKXXGHSs77XlkYFUiIqWaL0XFgymL1iprZV8';
//twitter-twetest
self::$oauth_callback = self::$hostname . "/twitter/page2.php";
//twitter-twetest
self::$fb_app_id = '138321036207048';
//$auth_header = header('WWW-Authenticate: Basic realm="My Realm"',true,401); //
//self::$doctype = $auth_header.self::$doctype; //
} else {
exit("Error: server not found");
}
}
//..........................................................................
if (isset($_SESSION['useragent']) && $_SESSION['useragent'] == 'device') {
self::$css = "/scripts/main.css";
//docroot not included for href tags..
} else {
self::$css = "/scripts/main.css";
//docroot not included for href tags..
}
//.............................................................................
//..........................................................................
self::$footer = '';
self::$footer .= "\n<div class='footer'>\nViewista, Inc. © 2010 <br /> \n<a href='http://twitter.com/twextradotcom'>Follow On Twitter</a> |\n<a href='" . self::$hostname . "/contact.php'>Contact</a> |\n<a href='" . self::$hostname . "/about.php'>About</a> |\n<a href='" . self::$hostname . "/privacy.php'>Privacy Policy</a> |\n<a href='" . self::$hostname . "/terms.php'>Terms</a> |\n<a href='" . self::$hostname . "/faqs.php'>FAQs</a> |\n<a href='http://twitter.com/twextradotcom'>Blog</a> |\n<a href='" . self::$hostname . "/api_support.php'>API Support</a>\n</div>";
//..........................................................................
$config_params = array('debug' => self::$debug, 'docroot' => self::$docroot, 'watch_demo' => self::$watch_demo, 'tweet_size_max' => self::$tweet_size_max, 'tweet_size_max_google' => self::$tweet_size_max_google, 'session_time_max' => self::$session_time_max, 'prefix_size_max' => self::$prefix_size_max, 'doctype' => self::$doctype, 'html_attribute' => self::$html_attribute, 'google_analytics' => self::$google_analytics, 'godaddy_analytics' => self::$godaddy_analytics, 'hostname' => self::$hostname, 'cookie_name' => self::$cookie_name, 'hostdb' => self::$hostdb, 'database' => self::$database, 'userdb' => self::$userdb, 'pwdb' => self::$pwdb, 'linkedin_access' => self::$linkedin_access, 'linkedin_secret' => self::$linkedin_secret, 'consumer_key' => self::$consumer_key, 'consumer_secret' => self::$consumer_secret, 'oauth_callback' => self::$oauth_callback, 'css' => self::$css, 'docroot' => $_SERVER['DOCUMENT_ROOT'], 'footer' => self::$footer, 'twitter_embedded_token_max' => self::$twitter_embedded_token_max, 'ep4' => self::$ep4, 'fb_app_id' => self::$fb_app_id);
return $config_params;
}
示例12: query
public final function query($sql = false)
{
if (!$sql) {
$this->compile();
}
$sql = $sql ? $sql : $this->sql;
//print_r($this);
//echo Config::database('table_pre').Config::cache('table');
if (Config::database('cache') && preg_match('/^SELECT/i', $sql) && (Config::database('table_pre') . Config::cache('table') != $this->table || Config::cache('driver') != 'dbCache')) {
//echo '开启缓存';
if (!Cache::is_cache(md5($sql), Config::database('cache_dir') . '/' . $this->section['table'])) {
$data = $this->_query($sql);
$cdata = '<?php exit;/*' . serialize($data) . '*/';
Cache::set(md5($sql), $cdata, Config::database('cache_dir') . '/' . $this->section['table']);
//Cache::$cache->writeCache($sql,$data,(Config::database('cache_dir').'/'.$this->section['table']));
Debug::add('DB:Update Cache ' . $sql, 2);
} else {
//$data=Cache::$cache->readCache($sql,(Config::database('cache_dir').'/'.$this->section['table']));
$data = unserialize(substr(Cache::get(md5($sql), Config::database('cache_dir') . '/' . $this->section['table']), 13, -2));
//exit();
Debug::add('DB:Read Cache' . $sql, 2);
}
$this->_reset();
if ($data == null) {
//防止直接返回Null
$data = array();
}
return $data;
} else {
Debug::add($sql, 2);
$this->_reset();
$data = $this->_query($sql);
if ($data == null) {
//防止直接返回Null
$data = array();
}
return $data;
}
}
示例13: category
/**
* 获取一个栏目
* @param $cid
* @return mixed
*/
public function category($cid)
{
//===判断是否已经放入内存
if (isset($this->category[$cid])) {
return $this->category[$cid];
}
$category = model('category')->where('cid', intval($cid))->getOne('catetable,cat_modelid');
$catetable = $category['catetable'];
$mid = $category['cat_modelid'];
if (empty($catetable)) {
return array();
}
$category = model($catetable)->leftJoin('category', $catetable . '.id', 'category.catid')->where(Config::database('table_pre') . 'category.cid', intval($cid))->getOne();
if (empty($category)) {
return array();
}
$parent = $category['parent'];
$view = $this->getCatView($category, $mid);
$category = model('model_field')->parse($mid, $category);
$category['pid'] = $parent;
unset($parent);
$category['cid'] = $cid;
$category['view'] = $view;
unset($view);
$category['url'] = $this->getCategoryUrl($cid, $mid);
$this->category[$category['cid']] = $category;
return $category;
}
示例14: table
public function table($table = '')
{
$this->db->table = Config::database('table_pre') . Config::database($table);
return $this;
}
示例15: delete_field
public function delete_field($fid)
{
if (is_array($fid)) {
foreach ($fid as $id) {
return $this->delete_field($id);
}
} else {
$field = $this->where('fieldid', intval($fid))->leftJoin('model', 'model.modelid', 'model_field.modelid')->getOne(array('model.tablename as tablename', 'model_field.name as fieldname', 'model_field.is_system as is_system'));
if ($field['is_system'] == 1) {
return false;
}
//print_r($field);
$table = Config::database('table_pre') . 'module_' . $field['tablename'];
$sql = 'ALTER TABLE ' . $table . ' DROP COLUMN ' . $field['fieldname'];
if ($this->exec($sql) !== false) {
return $this->where('fieldid', intval($fid))->delete();
} else {
return false;
}
}
return true;
}