We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • @Open,

    Awesome! Thanks for snippet. Once a bit deeper, I’ll relay feedback.

    However, regarding:
    Quote from: pixelchutes at Jan 23, 2007, 04:23 AM

    I couldn’t test the Person example on xPDO site per lack of table/class/map files. So, I created the table and the class, and as I looked at the map file, I realized I hadn’t created a table for the Person example, rather the xpdosample table... So, I needed to adjust the person example to match that of my table/map file...

    here is the example I am setting: (using the example xpdosample class/map files + manually created table w/ map file as reference)

    <?php
    $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();
    

    ...and the CREATE TABLE I used...
    CREATE TABLE `xpdosample` (                                                              
                  `parent` int(11) default NULL,                                                         
                  `unique_varchar` varchar(255) NOT NULL,                                                
                  `varchar` varchar(100) NOT NULL,                                                       
                  `text` text,                                                                           
                  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,  
                  `unix_timestamp` int(11) NOT NULL,                                                     
                  `date_time` datetime NOT NULL,                                                         
                  `date` date NOT NULL,                                                                  
                  `enum` enum('','T','F') NOT NULL,                                                      
                  `password` varchar(255) NOT NULL,                                                      
                  `integer` int(11) NOT NULL,                                                            
                  `boolean` binary(1) NOT NULL,                                                          
                  UNIQUE KEY `unique_varchar` (`unique_varchar`)                                         
                ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='My first xPDO Test ;)'  
    


    All works (connection established, etc) until I uncomment the save() method. Error indicates a missing driver?


    Fatal error: Uncaught exception ’PDOException’ with message ’could not find driver’ in /home/username/public_html/xpdo/xpdo.class.php:293 Stack trace: #0

    Hmm..looks like it’s the connect method for xPDO-class, and doesn’t like this line:
    <?php
    $this->pdo= new PDO($this->config['dsn'], $this->config['username'], $this->config['password'], $this->config['driverOptions']);
    


    Hmm, well, I’m runnin PHP 5.1.6, is it possible that PDO isn’t available to me? I’ll see if I can confirm...

    phpinfo() revealed:


    PDO support enabled
    PDO drivers sqlite2

    Well, on the php.net PDO page, it states that if on PHP 5.1+ (which I am) PDO and PDO_SQLITE are included in the distribution, and are automatically enabled by running configure...Also, You may also need to enable the PDO driver for your database of choice:
    [*] PDO Drivers: http://www.php.net/manual/en/ref.pdo.php#pdo.drivers (Reference MySQL 3.x and 4.x )

    Oh no! I am running MySQL 5.0.27-standard! Can I still use xPDO? sad
      Mike Reid - www.pixelchutes.com
      MODx Ambassador / Contributor
      [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
      ________________________________
      Where every pixel matters.
    • Maybe this can help, or at least get you on the right track

      http://forums.mysql.com/read.php?52,126024,126875#msg-126875
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
      • Quote from: pixelchutes at Jan 23, 2007, 05:53 AM

        All works (connection established, etc) until I uncomment the save() method. Error indicates a missing driver?
        phpinfo() revealed:


        PDO support enabled
        PDO drivers sqlite2

        Well, on the php.net PDO page, it states that if on PHP 5.1+ (which I am) PDO and PDO_SQLITE are included in the distribution, and are automatically enabled by running configure...Also, You may also need to enable the PDO driver for your database of choice:
        [*] PDO Drivers: http://www.php.net/manual/en/ref.pdo.php#pdo.drivers (Reference MySQL 3.x and 4.x )

        Oh no! I am running MySQL 5.0.27-standard! Can I still use xPDO? sad
        You should have the pdo_mysql.so (or pdo_mysql.dll on windows) available in your PHP installation. I bet it just needs to be uncommented in your php.ini.
        • Great... I hope my shared host can assist! Really wish I had dedicated right now... Maybe xPDO will have to wait for me sad
            Mike Reid - www.pixelchutes.com
            MODx Ambassador / Contributor
            [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
            ________________________________
            Where every pixel matters.
          • Quote from: pixelchutes at Jan 23, 2007, 06:45 AM

            Great... I hope my shared host can assist! Really wish I had dedicated right now... Maybe xPDO will have to wait for me sad
            Can you not test/develop this locally? And, honestly, they either need to disable PDO altogether or at least enable some drivers for MySQL at least...unfortunately, that’s the one situation where I can’t find a way to get xPDO to work: the fact that the PDO class is available triggers the cascade that then requires the native PDO driver, rather than the emulated PDO drivers provided for systems using the emulated PDO class.

            Hmmm then again, you could force the loading of the emulated PDO, which will be able to find the driver...just find both instances of class_exists(’PDO’) in xpdo.class.php and remove them, altering the logic to load the xPDO-provided PDO class rather than the native PDO class already available and to set the XPDO_MODE constant to XPDO_MODE_EMULATED.
            • oooh, I like the sound of this... Where (in the docs perhaps?) can I find how to swap native PDO for xPDO? (As you described)
                Mike Reid - www.pixelchutes.com
                MODx Ambassador / Contributor
                [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                ________________________________
                Where every pixel matters.
              • Quote from: pixelchutes at Jan 23, 2007, 03:58 PM

                oooh, I like the sound of this... Where (in the docs perhaps?) can I find how to swap native PDO for xPDO? (As you described)
                That’s what I’m saying; it happens automatically based on the existence of the native PDO class extension that comes built into PHP 5.1+, and there is no easy way to test for the MySQL PDO driver without loading PDO, and then you’ve already loaded the class you now don’t want. You need to trick it, by hardcoding it and making sure the PDO class in the package gets loaded, rather than the PDO that exists in PHP.
                • Quote from: OpenGeek at Jan 23, 2007, 07:19 AM

                  Hmmm then again, you could force the loading of the emulated PDO, which will be able to find the driver...just find both instances of class_exists(’PDO’) in xpdo.class.php and remove them, altering the logic to load the xPDO-provided PDO class rather than the native PDO class already available and to set the XPDO_MODE constant to XPDO_MODE_EMULATED.

                  Couldn’t you set a (manually changed) override in a config (somewhere) so that it not only checks for class_exists(’PDO’), but also a PDO_DRIVER_COMPAT_MODE_OVERRIDE_CONFIG_ADDITION_OR_WHATEVER===false?
                    Ryan Thrash, MODX Co-Founder
                    Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • 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...
                    • 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...

                      ETA? Actively looking to develop, and am awaiting Shared Host response to enabling MySQL Drivers...I’d love to be the guinea pig for this alternate method, so please don’t hesitate to PM me if any "early releases" need to be validated wink
                        Mike Reid - www.pixelchutes.com
                        MODx Ambassador / Contributor
                        [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                        ________________________________
                        Where every pixel matters.