DB_DataObject: what am I missing?

From: Date: Sat, 22 Jan 2005 15:33:52 +0000
Subject: DB_DataObject: what am I missing?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17104@lists.php.net to get a copy of this message
Hi there! I am trying to use the DB_DataObject library from PEAR. I've created a table in a Mysql database: ---------------------------------------------------------------- CREATE TABLE note ( note_id int(11) NOT NULL auto_increment, title varchar(255) NOT NULL default '', content mediumtext NOT NULL, creation_time datetime NOT NULL default '0000-00-00 00:00:00', modified_time datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (note_id) ) TYPE=MyISAM; ---------------------------------------------------------------- and I've used the createTable utility to create the class (although I had to generate the class on a different system because of a segfault in PHP 4.3.10 - http://bugs.php.net/bug.php?id=31106): ---------------------------------------------------------------- <?php /** * Table Definition for note */ require_once 'DB/DataObject.php'; class DataObjects_Note extends DB_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ var $__table = 'note'; // table name var $note_id; // int(11) not_null primary_key auto_increment var $title; // string(255) not_null var $content; // blob(16777215) not_null blob var $creation_time; // datetime(19) not_null var $modified_time; // datetime(19) not_null /* ZE2 compatibility trick*/ function __clone() { return $this;} /* Static get */ function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_Note',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE } ---------------------------------------------------------------- and the my_database.ini file: ---------------------------------------------------------------- [note] note_id = 129 title = 130 content = 194 creation_time = 142 modified_time = 142 [note__keys] note_id = N ---------------------------------------------------------------- Everything is ok until now and I trying to create and use a DataObjects_Note object: ---------------------------------------------------------------- <?php require_once ('PEAR.php') ; // configuration for PEAR::DB_DataObject $dataobject_options = &PEAR::getStaticProperty('DB_DataObject','options'); $dataobject_options = array( 'database' => 'mysql://user:pass@localhost/my_database', 'schema_location' => '/home/user/public_html/test/class/DataObjects', 'class_location' => '/home/user/public_html/test/class/DataObjects', 'require_prefix' => 'DataObjects/', 'class_prefix' => 'DataObjects_' ) ; DB_DataObject::debugLevel(5); $note = DB_DataObject::factory('note') ; $note->get(27); debug::var_dump($note); ?> ---------------------------------------------------------------- Looks like the $note object is a 'dataobjects_note' but empty: ---------------------------------------------------------------- object(dataobjects_note)(16)_DB_DataObject_version string(5) 1.7.2 __table string(4) note N int 0 _database_dsn string(0) _database_dsn_md5 string(0) _database string(0) _query array(6)condition string(0) group_by string(0) order_by string(0) having string(0) limit string(0) data_select string(1) * _DB_resultid NULL _link_loaded bool false _join string(0) _lastError bool false note_id NULL title NULL content NULL creation_time NULL modified_time NULL ---------------------------------------------------------------- Although, the db debug shows that the record is grabbed: ---------------------------------------------------------------- dataobjects_note: CONNECT: NEW CONNECTION dataobjects_note: CONNECT: mysql://user:pass@localhost/my_database 6e832c95de993b36266ded1b9c4806dc ... dataobjects_note: GET: note_id 27 Array ( [0] => note_id ) dataobjects_note: __find: 1 dataobjects_note: CONNECT: USING CACHED CONNECTION dataobjects_note: CONNECT: USING CACHED CONNECTION dataobjects_note: CONNECT: USING CACHED CONNECTION dataobjects_note: QUERY: SELECT * FROM note WHERE note.note_id = 27 dataobjects_note: query: QUERY DONE IN 0.00065183639526367 seconds ... dataobjects_note: __find: CHECK autofetchd 1 dataobjects_note: __find: ABOUT TO AUTOFETCH dataobjects_note: FETCH: a:5:{s:7:"note_id";s:2:"27";s:5:"title";s:10:"PostgreSQL";s:7:"content";s:111:" \\d ~= desc \\dt Show Tables \\dT list datatypes \\df list functions \\di list indexes \\dv list views";s:13:"creation_time";s:19:"2005-01-05 13:20:15";s:13:"modified_time";s:19:"2005-01-05 13:20:15";} dataobjects_note: fetchrow LINE: note_id = 27 dataobjects_note: fetchrow LINE: title = PostgreSQL dataobjects_note: fetchrow LINE: content = \\d ~= desc \\dt Show Tables \\dT list datatypes \\df list functions \\di list indexes \\dv list views dataobjects_note: fetchrow LINE: creation_time = 2005-01-05 13:20:15 dataobjects_note: fetchrow LINE: modified_time = 2005-01-05 13:20:15 dataobjects_note: fetchrow: note DONE dataobjects_note: __find: DONE ---------------------------------------------------------------- I'm using PHP 4.3.10, with PEAR 1.3.4, DB_DataObject 1.7.2 and Var_Dump 1.0.1, and MySQL 4.0.22-standard. What am I doing wrong? Cheers, Paul

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