Re: Using DataObjects DB Error: Not Found
| From: | Alan Knowles | Date: | Wed, 22 Jan 2003 13:08:50 +0000 |
| Subject: | Re: Using DataObjects DB Error: Not Found | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-3402@lists.php.net to get a copy of this message | ||
Hooimeijer, Martijn wrote:
Hi Alan, Thanks for the reply! Yes, it must be something simple like that. I am just wondering: where do I put the code. In the generating of the code or in the use of the dataobject. not sure I get the meaning there. - normally the application at some point loads a configuration file, or sets some config vars. - at that point, usually doing the parse_ini_file, code from the manual should be done..it could be you are getting confused on the ini files - there is one 'config.ini', and one 'database.ini' - the first is the one you have to use with the | require_once('PEAR.php');
$options = &PEAR::getStaticProperty('DB_DataObject','options');
$config = parse_ini_file('dataobjects.config.ini',TRUE);
$options = $config['DB_DataObject'];
the other one is located automatically
|
I noticed that the $_database_dsn attribute was not generated into the dataobjects, so I added it manually (for now!). Then a connection to the database is possible. it's supposed to get that from the ini file (although it was designed to allow you to set it manually)
I could then retrieve data using dataobject->get(name, value). Somehow the primary keys are not recognized and performing a dataobject->get(1) yeah - as you have not loaded that ini file - which says which directory the database.ini file is located.
gives "ERROR No Keys available for persons", although the keys are given in the database.ini file. I guess this file is not picked up. It is unclear to me how and where these files are going to be picked up and by what mechanism, so it is difficult to know what goes wrong where. The internals of the DataObject are a bit of a mystery to me, even after staring at the code for some time. yeah once you get the jist of the config mechanism - it's quite easy :)Regards Alan
I want to conclude on a positive note though. I really like this package very much, because it provides a professional interface to databases, somewhat comparable to entity beans in a J2EE architecture. Keep up the good work! Martijn -----Original Message----- From: Alan Knowles [mailto:alan@akbkhome.com] Sent: Tuesday 21 January 2003 04:19 To: Martijn Hooimeijer Cc: 'pear-general@lists.php.net' Subject: Re: Using DataObjects DB Error: Not Found Have a go with the latest release, - it looks likely however that you have failed to load the config data into PEAR::getStaticPropery('DB_DataObject','options'); try just print_r(PEAR::getStaticPropery('DB_DataObject','options')); and see if there is any data in there Regards Alan Martijn Hooimeijer wrote:-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.comHello, 6 months ago I had generated and used DataObjects succesfully. I recently updated my Pear system (PEAR it self, and the DB DataObjectsfunctionality.The DB package already was the latest version). I could generate the DataObjects, but using them generated errors: DataObject.php: line 977; Undefined index: table_tablename DataObject.php: line 981; Undefined index: database DB.php: 260 Failed Opening 'DB/.php' for inclusion. The output from the DataObject generated: DB Error: not found. BTW. I did not change the DataObjects. I then reinstalled DB_DataObject 0.8. I then got errors that the database belonging to my database could not be found and the DataObjects would generate at all. What's up! Martijn Hooimeijer LogicaCMG Wijhaven 69 3011 WJ Rotterdam PO Box 22067 3003 DB Rotterdam T:+31 (0)10 206 1143 F: +31 (0)10 206 11 00 E: Martijn.Hooimeijer@logicacmg.com www.logicacmg.com This e-mail and any attachment is for authorised use by the intendedrecipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.