Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




DB_DataObject Get ID


how to get the ID of the object after calling $mydbdataobject->insert()?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Help Needed With DB_DataObject
I have just adopted a PHP project and need some help understanding
DB_DataObject. I've looked around on the web and can't find a simple
explanation.

Basically, my MySQL database has no tables. I have a createTable.php
script which I believe is a standard script, it runs but tell me "NO
TABLES". There is a function in the script called _createTableList()
which is looking for tables not finding any (I don't really
understand why there should be pre-existing tables when the script is
supposed to be creating them...)

I have .ini files which seem to describe the schema, and classes which
correspond to the entries in the .ini file - but no SQL, and I do not
understand how to get the schema into the database. I believe the
environment is set up correctly for the script to find the .ini files.

I hope that was clear, and I hope somebody here can advise me - I'm sure
it's simple enough for somebody who knows what they're doing with
DB_DataObject!

Using PHP5 btw, if that matters.

PEAR Db_DataObject: Joining And Grouping
I'm excited about using DB_DataObjects classes to interact with my database. Trouble is that there seem to be no resources/tutorials that deal with complex joins. The PEAR manual suggests you are better off feeding the raw query into $object->query(); Once you do that, however, how do you extract the result and render say:

I have tables for user, address, city, and county. I want to take my query and:

PEAR DB_DataObject Auto-generator Multiple Databases
I'm using the DB_DataObject script createTables.php to auto-generate
the necessary database schema on two databases. Using the .ini
approach (not the in-line PHP approach) to configure DB_DataObject in
my script. Everything is by the book, but I'm having a big problem:

Here's my main.ini file:
[DB_DataObject]

database_one = mysql://user:password@localhost/one
database_two = mysql://user:password@localhost/one
schema_location = /home/user/classes/dataobjects
class_location = /home/user/classes/dataobjects
require_prefix = /home/user/classes/dataobjects
class_prefix = DataObject_

And here's my database connect file:
<?php
// separate classes for each database
class DataObject_one extends DB_DataObject { var $_database = 'one' }
class DataObject_two extends DB_DataObject { var $_database = 'two' }
$config = parse_ini_file('/home/user/classes/main.ini', TRUE);
foreach($config as $class=>$value) {
$options = &PEAR::getStaticProperty($class,'options');
$options = $value;
}
$DB = DataObject_one::factory("tableName");
// etc...
?>

The problem is that the auto-generator createTables.php copies
everything into one directory, regardless of the number of databases
you enter in your .ini file, which means, as is the case for me in this
example, if you have two tables with the same name on different
databases, it'll keep overwriting the same file, and the resulting
class is the LAST one you enter in your .ini file.

So my question is this: is there a way to specify different
subdirectories for different databases in your initial configuration
file? If not, is there no other solution than giving every table a
unique name across an entire MySQL server if you don't want to do any
coding?


Copyright © 2005-08 www.BigResource.com, All rights reserved