本文整理汇总了PHP中Arrays::key_first方法的典型用法代码示例。如果您正苦于以下问题:PHP Arrays::key_first方法的具体用法?PHP Arrays::key_first怎么用?PHP Arrays::key_first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arrays
的用法示例。
在下文中一共展示了Arrays::key_first方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _checkconfig
/**
* checks a database configuration array, and set its defaults.
**/
private static function _checkconfig($dbname, $isdef = false)
{
// if not database name specified use array's name.
if (!isset(self::$_DDB['name']) || !self::$_DDB['name']) {
self::$_DDB['name'] = Arrays::key_first(self::$_DBS);
}
// if not hostname specified use localhost
if (!isset(self::$_DDB['hostname']) || !self::$_DDB['hostname']) {
self::$_DDB['hostname'] = 'localhost';
}
// if not username or password is specified, send error.
if (!isset(self::$_DDB['username']) || !self::$_DDB['username']) {
Core::error('VARREQ', 'LIBTIT', array(__CLASS__, 'username'));
}
if (!isset(self::$_DDB['password']) || !self::$_DDB['password']) {
Core::error('VARREQ', 'LIBTIT', array(__CLASS__, 'password'));
}
// self explanatory
if (!isset(self::$_DDB['prefix'])) {
self::$_DDB['prefix'] = '';
}
if (!isset(self::$_DDB['driver']) || !self::$_DDB['driver']) {
self::$_DDB['driver'] = 'mysql';
}
if (!isset(self::$_DDB['pconnect']) || !is_bool(self::$_DDB['pconnect'])) {
self::$_DDB['pconnect'] = true;
}
if (!isset(self::$_DDB['debug']) || !is_bool(self::$_DDB['debug'])) {
self::$_DDB['debug'] = true;
}
if (!isset(self::$_DDB['cache']) || !is_bool(self::$_DDB['cache'])) {
self::$_DDB['cache'] = false;
}
if (!isset(self::$_DDB['cachedir']) || !self::$_DDB['cachedir']) {
self::$_DDB['cachedir'] = CACH;
}
if (!is_writable(self::$_DDB['cachedir'])) {
Core::error('403DIR', 'LIBTIT', array(__CLASS__, 'cachedir'));
}
// detect charset and collation if necessary
if (!isset(self::$_DDB['charset']) || !self::$_DDB['charset']) {
self::$_DDB['charset'] = array_key_exists($chset, self::$_CHS) ? self::$_CHS[$chset][0] : '';
}
if (!isset(self::$_DDB['collat']) || !self::$_DDB['collat']) {
self::$_DDB['collat'] = array_key_exists($chset, self::$_CHS) ? self::$_CHS[$chset][1] : '';
}
}
示例2: _check
/**
* checks a database configuration array, and set its defaults.
**/
private static function _check()
{
// if not database name specified use array's name.
if (!isset(self::$INFO['name']) || !self::$INFO['name']) {
self::$INFO['name'] = Arrays::key_first(self::$_DBS);
}
// if not hostname specified use localhost
if (!isset(self::$INFO['hostname']) || !self::$INFO['hostname']) {
self::$INFO['hostname'] = 'localhost';
}
// if not username or password is specified, send error.
if (!isset(self::$INFO['username']) || !self::$INFO['username']) {
self::error('VARREQ', 'LIBTIT', array(__CLASS__, 'username'));
}
if (!isset(self::$INFO['password']) || !self::$INFO['password']) {
self::error('VARREQ', 'LIBTIT', array(__CLASS__, 'password'));
}
// self explanatory
if (!isset(self::$INFO['port']) || !self::$INFO['port']) {
self::$INFO['port'] = self::$PORT;
}
if (!isset(self::$INFO['prefix'])) {
self::$INFO['prefix'] = '';
}
if (!isset(self::$INFO['driver']) || !self::$INFO['driver']) {
self::$INFO['driver'] = Arrays::first(self::$_DRV);
}
if (!isset(self::$INFO['pconnect']) || !is_bool(self::$INFO['pconnect'])) {
self::$INFO['pconnect'] = true;
}
// persistent connection
if (!isset(self::$INFO['debug']) || !is_bool(self::$INFO['debug'])) {
self::$INFO['debug'] = true;
}
if (!isset(self::$INFO['cache']) || !is_bool(self::$INFO['cache'])) {
self::$INFO['cache'] = false;
}
if (!isset(self::$INFO['cachedir']) || !self::$INFO['cachedir']) {
self::$INFO['cachedir'] = CACH . 'DB/';
}
if (!file_exists(self::$INFO['cachedir'])) {
mkdir($INFO['cachedir'], 0777);
}
// send an error if the directory isn't writable
if (!is_writable(self::$INFO['cachedir']) === false) {
self::error('403DIR', 'LIBTIT', array(__CLASS__, 'cachedir'));
}
// detect charset and collation if necessary
$chset = Core::config('charset');
if (!isset(self::$INFO['charset']) || !self::$INFO['charset']) {
self::$INFO['charset'] = array_key_exists($chset, self::$_CHS) ? self::$_CHS[$chset][0] : '';
}
if (!isset(self::$INFO['collat']) || !self::$INFO['collat']) {
self::$INFO['collat'] = array_key_exists($chset, self::$_CHS) ? self::$_CHS[$chset][1] : '';
}
}