Problem in DB_DataObject use/setup
| From: | Ronald van Raaphorst | Date: | Wed, 10 Sep 2003 13:27:02 +0000 |
| Subject: | Problem in DB_DataObject use/setup | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-7688@lists.php.net to get a copy of this message | ||
Hi 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');
$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/mydatabase
schema_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_null primary_key
auto_increment
var $name; // string(80) not_null unique_key
multiple_key
var $categoryid; // int(6) not_null multiple_key
var $articlegroupid; // int(8) not_null multiple_key
/* 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