Re: DB_DataObject

From: Date: Fri, 20 Aug 2004 17:13:32 +0000
Subject: Re: DB_DataObject
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-14200@lists.php.net to get a copy of this message
On Fri, 20 Aug 2004 16:29:43 +0200, Romain Fevre <rfevre@falco.fr> wrote: > Hello, > > I want to use the DB_DataObject package with MySQL. In my database, I have one table : > 'BOOK'. > All my classes (based on my database) have been generated with the CreateTables.php. When I try > to write the following code, i have always the same error : « DB_DataObject Error: factory could > not find class from book ».. > I look for a solution and a good explication because on my error should help me later. > Have you read the documentation for DataObject? I can't see from your code if you're setting up and reading an ini file. You *need* that to tell DataObject where to load your classes from. You also need it to tell it where the database.ini file is, which tells DataObject what the types of the fields for a table are. Read this: http://pear.php.net/manual/en/package.database.db-dataobject.intro-configuration.php > <?php > require_once('DB/DataObject.php'); > require('Config.php'); > require_once('include/classes/ObjectBase/Book.php'); You don't have to require this, the factory will do it for you when properly configured. > > $book = &DB_DataObject::factory('book'); > > if(strcasecmp('db_dataobject_error',get_class($book))==0){ This should be: if (PEAR::isError($book)) { > echo $book->getMessage(); > } > else{ > $book->get(1); > echo 'This book is called: '.$book->title; > } > ?> > > PS : sorry for my poor english -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin--

« previous php.pear.general (#14200) next »