cvs: pear /DB_DataObject DataObject.php

From: Date: Sun, 18 Jan 2004 02:00:22 +0000
Subject: cvs: pear /DB_DataObject DataObject.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-15743@lists.php.net to get a copy of this message
alan_k Sat Jan 17 21:00:22 2004 EDT Modified files: /pear/DB_DataObject DataObject.php Log: rationalize the table schema autoload code. Index: pear/DB_DataObject/DataObject.php diff -u pear/DB_DataObject/DataObject.php:1.188 pear/DB_DataObject/DataObject.php:1.189 --- pear/DB_DataObject/DataObject.php:1.188 Fri Jan 16 04:17:07 2004 +++ pear/DB_DataObject/DataObject.php Sat Jan 17 21:00:20 2004 @@ -20,7 +20,7 @@ * @package DB_DataObject * @category DB * - * $Id: DataObject.php,v 1.188 2004/01/16 09:17:07 alan_k Exp $ + * $Id: DataObject.php,v 1.189 2004/01/18 02:00:20 alan_k Exp $ */ /* ===================================================================================== @@ -1388,6 +1388,8 @@ global $_DB_DATAOBJECT; + // Assignment code + if ($args = func_get_args()) { if (count($args) == 1) { @@ -1408,10 +1410,23 @@ } return true; } + + + + + // 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])) { + 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(); } @@ -1430,18 +1445,25 @@ } $links = str_replace('.ini','.links.ini',$ini); - if (!file_exists($ini)) { - return false; - + if (file_exists($ini)) { + $_DB_DATAOBJECT['INI'][$this->_database] = parse_ini_file($ini, true); } - $_DB_DATAOBJECT['INI'][$this->_database] = parse_ini_file($ini, true); - $_DB_DATAOBJECT['LINKS'][$this->_database] = array(); - /* load the link table if it exists. */ - if (file_exists($links)) { + + if (empty($_DB_DATAOBJECT['LINKS'][$this->_database]) && file_exists($links)) { /* not sure why $links = ... here - TODO check if that works */ $_DB_DATAOBJECT['LINKS'][$this->_database] = parse_ini_file($links, true); } + + // now have we loaded the structure.. - if not try building it.. + + if (empty($_DB_DATAOBJECT['INI'][$this->_database][$this->__table])) { + require_once 'DB/DataObject/Generator.php'; + $x = new DB_DataObject_Generator; + $x->fillTableSchema($this->_database,$this->__table); + } + + return true; } @@ -1508,14 +1530,7 @@ } $this->databaseStructure(); - - - - if (!isset($_DB_DATAOBJECT['INI'][$this->_database][$this->__table])) { - require_once 'DB/DataObject/Generator.php'; - $x = new DB_DataObject_Generator; - $x->fillTableSchema($this->_database,$this->__table); - } + $ret = array(); if (isset($_DB_DATAOBJECT['INI'][$this->_database][$this->__table])) { @@ -1554,12 +1569,6 @@ $this->_connect(); } $this->databaseStructure(); - // attempt autoload.. - if (!isset($_DB_DATAOBJECT['INI'][$this->_database][$this->__table])) { - require_once 'DB/DataObject/Generator.php'; - $x = new DB_DataObject_Generator; - $x->fillTableSchema($this->_database,$this->__table); - } if (isset($_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"])) { return array_keys($_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"]);

« previous php.pear.cvs (#15743) next »