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 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?