本文整理汇总了PHP中DB_DataObject::_loadConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP DB_DataObject::_loadConfig方法的具体用法?PHP DB_DataObject::_loadConfig怎么用?PHP DB_DataObject::_loadConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_DataObject
的用法示例。
在下文中一共展示了DB_DataObject::_loadConfig方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _loadConfig
public function _loadConfig()
{
// avoid those annoying PEAR::DB strict standards warnings it causes
$old = error_reporting();
error_reporting(error_reporting() & ~E_STRICT);
$res = parent::_loadConfig();
// reset
error_reporting($old);
return $res;
}
示例2: _getDbDsn
function _getDbDsn()
{
global $_DB_DATAOBJECT;
if (empty($_DB_DATAOBJECT['CONFIG'])) {
DB_DataObject::_loadConfig();
}
$options =& $_DB_DATAOBJECT['CONFIG'];
// if the databse dsn dis defined in the object..
$dsn = isset($this->_database_dsn) ? $this->_database_dsn : null;
if (!$dsn) {
if (!$this->_database) {
$this->_database = isset($options["table_{$this->__table}"]) ? $options["table_{$this->__table}"] : null;
}
if ($this->_database && !empty($options["database_{$this->_database}"])) {
$dsn = $options["database_{$this->_database}"];
} else {
if (!empty($options['database'])) {
$dsn = $options['database'];
}
}
}
if (!$dsn) {
// TRANS: Exception thrown when database name or Data Source Name could not be found.
throw new Exception(_('No database name or DSN found anywhere.'));
}
return $dsn;
}
示例3: debugLevel
/**
* sets and returns debug level
* eg. DB_DataObject::debugLevel(4);
*
* @param int $v level
* @access public
* @return none
*/
function debugLevel($v = null)
{
global $_DB_DATAOBJECT;
if (empty($_DB_DATAOBJECT['CONFIG'])) {
DB_DataObject::_loadConfig();
}
if ($v !== null) {
$r = isset($_DB_DATAOBJECT['CONFIG']['debug']) ? $_DB_DATAOBJECT['CONFIG']['debug'] : 0;
$_DB_DATAOBJECT['CONFIG']['debug'] = $v;
return $r;
}
return isset($_DB_DATAOBJECT['CONFIG']['debug']) ? $_DB_DATAOBJECT['CONFIG']['debug'] : 0;
}
示例4: databaseStructure
/**
* Work around memory-leak bugs...
* Had to copy-paste the whole function in order to patch a couple lines of it.
* Would be nice if this code was better factored.
*
* @param optional string name of database to assign / read
* @param optional array structure of database, and keys
* @param optional array table links
*
* @access public
* @return true or PEAR:error on wrong paramenters.. or false if no file exists..
* or the array(tablename => array(column_name=>type)) if called with 1 argument.. (databasename)
*/
function databaseStructure()
{
global $_DB_DATAOBJECT;
// Assignment code
if ($args = func_get_args()) {
if (count($args) == 1) {
// this returns all the tables and their structure..
if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
$this->debug("Loading Generator as databaseStructure called with args", 1);
}
$x = new DB_DataObject();
$x->_database = $args[0];
$this->_connect();
$DB =& $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
$tables = $DB->getListOf('tables');
class_exists('DB_DataObject_Generator') ? '' : (require_once 'DB/DataObject/Generator.php');
foreach ($tables as $table) {
$y = new DB_DataObject_Generator();
$y->fillTableSchema($x->_database, $table);
}
return $_DB_DATAOBJECT['INI'][$x->_database];
} else {
$_DB_DATAOBJECT['INI'][$args[0]] = isset($_DB_DATAOBJECT['INI'][$args[0]]) ? $_DB_DATAOBJECT['INI'][$args[0]] + $args[1] : $args[1];
if (isset($args[1])) {
$_DB_DATAOBJECT['LINKS'][$args[0]] = isset($_DB_DATAOBJECT['LINKS'][$args[0]]) ? $_DB_DATAOBJECT['LINKS'][$args[0]] + $args[2] : $args[2];
}
return true;
}
}
if (!$this->_database) {
$this->_connect();
}
// loaded already?
if (!empty($_DB_DATAOBJECT['INI'][$this->_database])) {
// database loaded - but this is table is not available..
if (empty($_DB_DATAOBJECT['INI'][$this->_database][$this->__table]) && !empty($_DB_DATAOBJECT['CONFIG']['proxy'])) {
if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
$this->debug("Loading Generator to fetch Schema", 1);
}
class_exists('DB_DataObject_Generator') ? '' : (require_once 'DB/DataObject/Generator.php');
$x = new DB_DataObject_Generator();
$x->fillTableSchema($this->_database, $this->__table);
}
return true;
}
if (empty($_DB_DATAOBJECT['CONFIG'])) {
DB_DataObject::_loadConfig();
}
// if you supply this with arguments, then it will take those
// as the database and links array...
$schemas = isset($_DB_DATAOBJECT['CONFIG']['schema_location']) ? array("{$_DB_DATAOBJECT['CONFIG']['schema_location']}/{$this->_database}.ini") : array();
if (isset($_DB_DATAOBJECT['CONFIG']["ini_{$this->_database}"])) {
$schemas = is_array($_DB_DATAOBJECT['CONFIG']["ini_{$this->_database}"]) ? $_DB_DATAOBJECT['CONFIG']["ini_{$this->_database}"] : explode(PATH_SEPARATOR, $_DB_DATAOBJECT['CONFIG']["ini_{$this->_database}"]);
}
/* BEGIN CHANGED FROM UPSTREAM */
$_DB_DATAOBJECT['INI'][$this->_database] = $this->parseIniFiles($schemas);
/* END CHANGED FROM UPSTREAM */
// now have we loaded the structure..
if (!empty($_DB_DATAOBJECT['INI'][$this->_database][$this->__table])) {
return true;
}
// - if not try building it..
if (!empty($_DB_DATAOBJECT['CONFIG']['proxy'])) {
class_exists('DB_DataObject_Generator') ? '' : (require_once 'DB/DataObject/Generator.php');
$x = new DB_DataObject_Generator();
$x->fillTableSchema($this->_database, $this->__table);
// should this fail!!!???
return true;
}
$this->debug("Cant find database schema: {$this->_database}/{$this->__table} \n" . "in links file data: " . print_r($_DB_DATAOBJECT['INI'], true), "databaseStructure", 5);
// we have to die here!! - it causes chaos if we don't (including looping forever!)
// Low level exception. No need for i18n as discussed with Brion.
$this->raiseError("Unable to load schema for database and table (turn debugging up to 5 for full error message)", DB_DATAOBJECT_ERROR_INVALIDARGS, PEAR_ERROR_DIE);
return false;
}
示例5:
function _loadConfig()
{
global $_DB_DATAOBJECT;
if (!isset($_DB_DATAOBJECT['CONFIG'])) {
parent::_loadConfig();
}
// Set DB Driver as MDB2
$_DB_DATAOBJECT['CONFIG']['db_driver'] = 'MDB2';
}
示例6: _generateClassTable
/**
* The table class geneation part - single file.
*
* @access private
* @return none
*/
function _generateClassTable($input = '')
{
// title = expand me!
$foot = "";
$head = "<?php\n/**\n * Table Definition for {$this->table}\n";
$head .= $this->derivedHookPageLevelDocBlock();
$head .= " */\n";
$head .= $this->derivedHookExtendsDocBlock();
// requires
$head .= "require_once '{$this->_extendsFile}';\n\n";
// add dummy class header in...
// class
$head .= $this->derivedHookClassDocBlock();
$head .= "class {$this->classname} extends {$this->_extends} \n{";
$body = "\n ###START_AUTOCODE\n";
$body .= " /* the code below is auto generated do not remove the above tag */\n\n";
// table
$padding = 30 - strlen($this->table);
$padding = $padding < 2 ? 2 : $padding;
$p = str_repeat(' ', $padding);
$options =& PEAR::getStaticProperty('DB_DataObject', 'options');
$var = substr(phpversion(), 0, 1) > 4 ? 'public' : 'var';
$var = !empty($options['generator_var_keyword']) ? $options['generator_var_keyword'] : $var;
$body .= " {$var} \$__table = '{$this->table}'; {$p}// table name\n";
// if we are using the option database_{databasename} = dsn
// then we should add var $_database = here
// as database names may not always match..
if (empty($GLOBALS['_DB_DATAOBJECT']['CONFIG'])) {
DB_DataObject::_loadConfig();
}
// Only include the $_database property if the omit_database_var is unset or false
if (isset($options["database_{$this->_database}"]) && empty($GLOBALS['_DB_DATAOBJECT']['CONFIG']['generator_omit_database_var'])) {
$body .= " {$var} \$_database = '{$this->_database}'; {$p}// database name (used with database_{*} config)\n";
}
if (!empty($options['generator_novars'])) {
$var = '//' . $var;
}
$defs = $this->_definitions[$this->table];
// show nice information!
$connections = array();
$sets = array();
foreach ($defs as $t) {
if (!strlen(trim($t->name))) {
continue;
}
if (!preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $t->name)) {
echo "*****************************************************************\n" . "** WARNING COLUMN NAME UNUSABLE **\n" . "** Found column '{$t->name}', of type '{$t->type}' **\n" . "** Since this column name can't be converted to a php variable **\n" . "** name, and the whole idea of mapping would result in a mess **\n" . "** This column has been ignored... **\n" . "*****************************************************************\n";
continue;
}
$padding = 30 - strlen($t->name);
if ($padding < 2) {
$padding = 2;
}
$p = str_repeat(' ', $padding);
$length = empty($t->len) ? '' : '(' . $t->len . ')';
$body .= " {$var} \${$t->name}; {$p}// {$t->type}{$length} {$t->flags}\n";
// can not do set as PEAR::DB table info doesnt support it.
//if (substr($t->Type,0,3) == "set")
// $sets[$t->Field] = "array".substr($t->Type,3);
$body .= $this->derivedHookVar($t, $padding);
}
// THIS IS TOTALLY BORKED old FC creation
// IT WILL BE REMOVED!!!!! in DataObjects 1.6
// grep -r __clone * to find all it's uses
// and replace them with $x = clone($y);
// due to the change in the PHP5 clone design.
if (substr(phpversion(), 0, 1) < 5) {
$body .= "\n";
$body .= " /* ZE2 compatibility trick*/\n";
$body .= " function __clone() { return \$this;}\n";
}
// simple creation tools ! (static stuff!)
$body .= "\n";
$body .= " /* Static get */\n";
$body .= " function staticGet(\$k,\$v=NULL) { return DB_DataObject::staticGet('{$this->classname}',\$k,\$v); }\n";
// generate getter and setter methods
$body .= $this->_generateGetters($input);
$body .= $this->_generateSetters($input);
/*
theoretically there is scope here to introduce 'list' methods
based up 'xxxx_up' column!!! for heiracitcal trees..
*/
// set methods
//foreach ($sets as $k=>$v) {
// $kk = strtoupper($k);
// $body .=" function getSets{$k}() { return {$v}; }\n";
//}
if (!empty($options['generator_no_ini'])) {
$def = $this->_generateDefinitionsTable();
// simplify this!?
$body .= $this->_generateTableFunction($def['table']);
$body .= $this->_generateKeysFunction($def['keys']);
$body .= $this->_generateSequenceKeyFunction($def);
$body .= $this->_generateDefaultsFunction($this->table, $def['table']);
//.........这里部分代码省略.........
示例7: debugLevel
/**
* sets and returns debug level
* eg. DB_DataObject::debugLevel(4);
*
* @param int $v level
* @access public
* @return none
*/
function debugLevel($v = NULL)
{
global $_DB_DATAOBJECT;
if (empty($_DB_DATAOBJECT['CONFIG'])) {
DB_DataObject::_loadConfig();
}
if ($v !== NULL) {
$_DB_DATAOBJECT['CONFIG']['debug'] = $v;
}
return @$_DB_DATAOBJECT['CONFIG']['debug'];
}