Is this functionality intentional? Shouldn't DataObject be passing the
options I define to the driver?
No, DB_DataObject doesn't have that option. What you *should* be doing
is setting what DB_DataObject is reading, namely PEAR "static
properties" for MDB2. Same basic thing as your DB_DO options:
$o =& PEAR::getStaticProperty('MDB2', 'options');
$o = array('portability' => MDB2_PORTABILITY_NONE);
Below is my ini file. I've gotten the settings from the documentation and also from various examples within. This ini file was initially written so I could run the createTables.php script to create classes for all my tables.
"DataObject.ini"
[DB_DataObject]
database = mysql://user:password@myserver/communal_haven
schema_location = /location
class_location = /location
require_prefix = DataObjects/
class_prefix =
debug = 5
field_case =
portability = DB_PORTABILITY_NONE
db_driver = MDB2
[MDB2]
portability = MDB2_PORTABILITY_NONE
I just added the [MDB2] section last night while trying to figure all of this out, though I'm not entirely too sure whether I need it at all.
Below is the php script that I include in every other php script that uses my classes. This, too, was culled from the documentation and various examples.
<script language="php">
require 'DB.php';
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
$config = parse_ini_file('DataObject.ini', TRUE);
$options = $config['DB_DataObject']
</script>
If I output the structure of $options at this point, it looks like this:
$options
Array
(
[database] => mysql://user:password@myserver/communal_haven
[schema_location] => /location [class_location] => /location [require_prefix] => DataObjects/
[class_prefix] =>
[debug] => 5
[field_case] =>
[portability] => 0
[db_driver] => MDB2
)I'm confused about several things. One, what does getStaticProperty (in using DB_DataObject) really do with any of the configurations I'm setting? I don't see where DataObject is calling setOptions() for the MDB2 driver using the options I've already defined. So I don't see how there is anything I can do in my ini file (or anywhere else in my code for that matter) where I can define the portability option for MDB2 if line 2212 of DataObject is just getting the options defined within the MDB2 class. Consequently, I'm not sure how my included setup file immediately above would behave any differently if I replaced 'DB_DataObject' with 'MDB2'.
This leads to my second bit of confusion. Both DB_DataObject and MDB2 are looking to $options['portability'] to get the portability value. DB_PORTABILITY_NONE and MDB2_PORTABILITY_NONE are both defined as 0. So I'm not sure why it matters which I use so long as it resolves to 0. As you can see above, my $options array has portability set to exactly that.
Here is the (partial) structure of $_DB_DATAOBJECT as of line 2214 of DataObject.php:
$_DB_DATAOBJECT:
Array
(
[CONNECTIONS] => Array
(
[md5string] => MDB2_Driver_mysql Object
(
[options] => Array
(
[ssl] =>
[field_case] => 0
[disable_query] =>
[result_class] => MDB2_Result_%s
[buffered_result_class] => MDB2_BufferedResult_%s
[result_wrap_class] =>
[result_buffering] => 1
[fetch_class] => stdClass
[persistent] =>
[debug] => 0
[debug_handler] => MDB2_defaultDebugOutput
[debug_expanded_output] =>
[default_text_field_length] => 4096
[lob_buffer_length] => 8192
[log_line_break] =>
[idxname_format] => %s_idx
[seqname_format] => %s_seq
[savepoint_format] => MDB2_SAVEPOINT_%s
[seqcol_name] => sequence
[quote_identifier] =>
[use_transactions] => 1
[decimal_places] => 2
[portability] => 127
[modules] => Array
(
[ex] => Extended
[dt] => Datatype
[mg] => Manager
[rv] => Reverse
[na] => Native
[fc] => Function
)
)
)
[CONFIG] => Array
(
[database] => mysql://user:password@myserver/communal_haven
[schema_location] => /location
[class_location] => /location
[require_prefix] => DataObjects/
[class_prefix] =>
[debug] => 5
[field_case] =>
[portability] => 0
[db_driver] => MDB2
)
[OVERLOADED] => 1
[QUERYENDTIME] => 0
)
[CONFIG] contains the configuration directives I defined in my ini file. Everything is as expected. But notice in the value for portability in the options array of the MDB2_Driver_mysql object isn't set to 0. It is set to 127 (MDB2_PORTABILITY_ALL), which is hardcoded to initialized/set in the MDB2 class. Because line 2212 of DataObject.php is getting the options (which are passed to the MDB2_Driver_mysql class) from PEAR::getStaticProperty and nowhere else, I'm not sure where I can put any of my code to ever make it so that the driver has a portibility value of 0.
I'm still trying to piece together how all this works and I really appreciate you taking the time and effort to help me out.
thnx,
Chris