Quote from: OpenGeek at Jan 23, 2007, 07:12 PM
Indeed, I am modifying the xpdo class to allow this by simply defining the constant XPDO_MODE with a value of 2 before including the main xpdo.class.php. Will be available in the next release...
Pretty sure I did this right, but doesn’t seem to be working... am I missing something:
My Snippet:
<?php
global $modx;
define('XPDO_MODE', 2 );
// Require magic beans
include_once ( $modx->config['base_path'] . 'xpdo/xpdo.class.php');
// Plant bean
$xpdo= new xPDO('mysql:host=localhost;dbname=modx', "user", "pass");
$sample= $xpdo->newObject('xpdosample');
$sample->set('parent', null );
$sample->set('unique_varchar', 'row_one');
$sample->set('varchar', 'hello world');
$sample->set('text', 'xPDO Sample');
$sample->set('timestamp', date('H:i:s'));
$sample->set('unix_timestamp', time() );
$sample->set('date_time', date('Y-m-d H:i:s'));
$sample->set('date', date('Y-m-d'));
$sample->set('enum', 'T');
$sample->set('password', md5('password'));
$sample->set('integer', 13);
$sample->set('boolean', 1);
$sample->save();
return var_export($sample->_fields); //'working... ;)
?>
Fatal error: Uncaught exception ’PDOException’ with message ’could not find driver’
I grabbed the newest SVN from:
svn://victorland.com/xpdo/trunk
I even tried the following (outside of the snippet):
<?php
/**#@+
* @var integer
* @access public
*/
define('XPDO_MODE', 2); // pixelchutes disabled MySQL drivers test (non-native PDO)
define('XPDO_MODE_NATIVE', 1);
define('XPDO_MODE_EMULATED', 2);
//...
No cigar.
...looking around, I couldn’t find any other references to:
... so when $this->_nativeMode evaluates to FALSE (XPDO_MODE, 2||Emulated), where does _nativeMode attribute control loading the emulated PDO class? Oh, here it is:
# Original // if (class_exists('PDO') || include_once (XPDO_CORE_PATH . 'pdo.class.php')) {
// So I try this way...
if ( include_once (XPDO_CORE_PATH . 'pdo.class.php')) {
Unfortunately, I never make it past the
|| because in my case, PDO class exists, just that the drivers are missing. Guess I’ll have to uncomment that class_exists...
...and the result:
Fatal error: Cannot redeclare class pdo in /home/username/public_html/xpdo/pdo.class.php on line 49
:( Looks like PDO is auto_loading as a result of class_exists(’PDO’) call (by nature of the function in PHP 5.1+) ...removing it unfortunately does not prevent its creation, as it seems PHP is auto_loading PHP anyhow