Re: Re: Problem in DB_DataObject use/setup
| From: | Ron McClain | Date: | Thu, 11 Sep 2003 00:58:29 +0000 |
| Subject: | Re: Re: Problem in DB_DataObject use/setup | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-7712@lists.php.net to get a copy of this message | ||
Try:
$config = parse_ini_file('DataObject.ini', true);
Ronald van Raaphorst wrote:
Hi Alan, Thanks, Now I know my dsn is empty in DB::Connect... But I have it in my DataObject.ini file...., which is loaded by the config.php as follows: DataObject.ini contains: [DB_DataObject]database = mysql://IAm:MyPasword@localhost/mydatabaseconfig.php <?php require_once('PEAR.php'); $options = &PEAR::getStaticProperty('DB_DataObject','options'); $config = parse_ini_file('DataObject.ini'); $options = $config['DB_DataObject']; ?> Now, do I need to do more than to include this in my script? Is there any example out there of how what I am supposed to do in my script, except for the above... 10 years as a programmer in other languages leave me clueless of what the authors of the pear, DB and DataObject authors expect from me to initialize. The pity is that there is no full example in the manual, only pieces... TIA Ronald "Alan Knowles" <alan@akbkhome.com> schreef in bericht news:3F5FBE52.3080109@akbkhome.com...Ronald Van Raaphorst wrote:primary_keyHi all, I'm having a faily difficult time at getting started... I'm trying to get a simple DB_Dataobject started, as described in the manual, but I got an error DB Error: not found Now, my test scripts looks like: <?php require_once('Config.php'); require_once('DataObjects/Article.php');try adding DB_DataObject::debugLevel(5); It could be a number of things: a) DB/mysql.php is not in the path or not found.. - remove the @ infront of the include line in DB.php DB::connect() b) you do not have mysql compiled in... c) password/database name is wrong? Regards Alan$article = new DataObjects_Article; $article->get('29'); // I know this record is in there... (article.id) print_r($article); ?> I have problems with the fact that there are puzzle pieces anywhere, but not an example of the complete puzzle. What do I miss to perform the right setup? What I have done is this: On my site (at the ISP), I have defined a Pear map, which contains: Config.php DataObject.ini DataObject.php DB.php PEAR.php test.php DataObjects (MAP) Article.php (Generated witht the createTables.php) Category.php ( "" ) mydatabase.ini DB (MAP) common.php mysql.php Config.php contains: <?php require_once('PEAR.php'); $options = &PEAR::getStaticProperty('DB_DataObject','options'); $config = parse_ini_file('DataObject.ini'); $options = $config['DB_DataObject']; ?> DataObject.ini contains: [DB_DataObject]database = mysql://IAm:MyPasword@localhost/mydatabaseschema_location = /usr/local/slash/apache/vhosts/www.MySite.com/httpdocs/Pear/DataObjects class_location = /usr/local/slash/apache/vhosts/www.MySite.com/httpdocs/Pear/DataObjects require_prefix = DataObjects/class_prefix = DataObjects_extends_location = extends = generator_class_rewrite = debug = 3 debug_ignore_updates = 0 dont_die = 0 DataObjects\Article.php looks like: <?php /** * Table Definition for article */ require_once 'DataObject.php'; class DataObjects_Article extends DB_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */var $__table = 'article'; // table name var $id; // int(8) not_nullunique_keyauto_incrementvar $name; // string(80) not_nullmultiple_keymultiple_keyvar $categoryid; // int(6) not_nullmultiple_keyvar $articlegroupid; // int(8) not_null/* ZE2 compatibility trick*/ function __clone() { return $this;} /* Static get */ function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Article',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE } ?> TIA Ronald