Re: Problem in DB_DataObject use/setup
| From: | Ronald van Raaphorst | Date: | Thu, 11 Sep 2003 07:21:18 +0000 |
| Subject: | Re: Problem in DB_DataObject use/setup | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-7711@lists.php.net to get a copy of this message | ||
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/mydatabase
config.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:
> > 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');
>
> 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/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