SitePoint Sponsor

User Tag List

Results 1 to 17 of 17

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    i'm going with pdo.. good or bad idea?

    I primarily use mysql however the past 6 months i've been developing in mssql. So i need support for both.


    I thought about dbx but looks like pdo is the db abstraction layer from php.net

    http://us2.php.net/pdo
    PDO ships with PHP 5.1, and is available as a PECL extension for PHP 5.0; PDO requires the new OO features in the core of PHP 5, and so will not run with earlier versions of PHP.


    http://us2.php.net/dbx
    Note: This extension has been moved to the PECL repository and is no longer bundled with PHP as of PHP 5.1.0.



    Then there is adodb which my current application extensively uses.
    Problem is i wished it used exceptions.
    And i originally got it because it had caching ability.. bad reason for me to choose it.
    known to slow the application




    The there is
    Propel which most new php frameworks use with Creole
    http://propel.phpdb.org/trac/wiki/Users/Introduction
    http://creole.phpdb.org/trac/

    Which i've never used.


    is pdo a good choice?


    note: version is not a problem i host my own sites and have full control over everything.

  2. #2
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by leblanc
    Then there is adodb which my current application extensively uses.
    Problem is i wished it used exceptions.
    But it does: http://phplens.com/lens/adodb/docs-adodb.htm#php5

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Propel is a full blown object-relational mapping tool. Creole however is comparable to PDO, and in fact the author of Propel wishes to switch over from Creole to PDO at some stage in the future for performance reasons (PDO is a C extension, Creole is straight PHP).

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    VA, USA
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, Propel 2, which is currently under development uses PDO (instead of Creole). As mentioned, Propel is not really comparable to PDO, as it is an ORM layer, not a database API abstraction layer.

  5. #5
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BerislavLopac that is good to hear, however, i think for future development i need to make the switch.

    I have to look into what an ORM layer is. Most of my work has been as follows: create a win form application to do some grunt work.

    Example:
    At work we have a parameter generator [windows forms] that queries mssql and populates the command object with the parameters in the stored procedure then we copy and paste the generated code into our code.

    elminates that tedious work of creating the server side code.
    cmd.Parameters.Add()
    http://msdn2.microsoft.com/en-us/library/80x06z3b.aspx


    I'll read more into this when i have a chance:
    http://www.sitepoint.com/forums/show...&highlight=ORM

  6. #6
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A lot of hosts don't provide PHP5.1 so be careful, but if you control the environment, go for it

  7. #7
    SitePoint Guru
    Join Date
    May 2005
    Location
    Finland
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    A lot of hosts don't provide PHP5.1 so be careful, but if you control the environment, go for it
    I heard 5.1 was the most common version on servers that actually have PHP 5. Could be ********, or could just vary a lot, but there you go.

  8. #8
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    According to the Nexen.net PHP Usage stats for June 2006, usage of PHP 5.0.4 and 5.0.5 is really close to 5.1.2 and 5.1.4, with 5.1 having slightly more usage. However, if you look at the evolution of version usage over the past year, 5.0 has barely changed and looks to be slightly declining now, while 5.1 has been significantly increasing each month since December. Its' gone from 0% usage to nearly 5% usage in about 6 months.

    http://www.nexen.net/chiffres_cles/p..._june_2006.php
    http://www.nexen.net/chiffres_cles/p..._june_2006.php

    I don't see anything wrong with targeting 5.1. It's far superior to 5.0, now has more usage than 5.0 and will only keep rising past 5.0 usage. And as more PHP 4 hosts switch to or offer PHP 5, they're not going to backtrack to 5.0; they're going to jump right to 5.1.

    You've got forgive the good doctor. He's got a love affair with PHP 5.0 for some reason that I've never understood, but regardless sticking his head in the sand and making **** up doesn't make it true or valid.

  9. #9
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Umm...

    Well, I don't in particular have a love affair with PHP5.0.x but my excuse (I suppose) is that my host hasn't upgraded to PHP5.1.x so I see no reason to upgrade either.

    As for making **** up, well I don't see how you arrived at that conclusion? I was merely recommending to use PDO if said member has control over their environment. On the other hand, maybe more and more hosts have moved directly to PHP5.1.x, or not.

    The hosts I've looked at (6 months ago, or so) were all PHP5.0.x.

  10. #10
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    As for making **** up, well I don't see how you arrived at that conclusion?
    I guess you forgot your glasses again maybe :shruggs:

    >> A lot of hosts don't provide PHP5.1 so be careful

    According to the most recent survey, there are more 5.1 hosts than 5.0 hosts (barely more, but more), and 5.1 hosts are on the rise while 5.0 hosts are not. So saying "A lot of hosts don't provide PHP5.1 so be careful" without evidence, could be called "making **** up"

  11. #11
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looking at those links, kind of suggests that indeed PHP5.1.x has taken some ground, so maybe there is something in that.

    >>> A lot of hosts don't provide PHP5.1 so be careful

    Take a good look around for hosting if you are after PHP5.1.x; Good luck finding a host

    As for wearing glasses, I don't wear any

  12. #12
    SitePoint Guru
    Join Date
    May 2005
    Location
    Finland
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    Quote Originally Posted by Dr Livingston
    As for wearing glasses, I don't wear any
    Well, perhaps you ought to.

  13. #13
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ORM layer

    great someone revived the thread


    well does anyone here use an ORM layer?

    what are some good practices that i need to keep in mind while researching this topic

    any simple concrete examples of what it is.

  14. #14
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi..

    ORM Layer usually takes care of persisting your objects into database as well as retrieving those objects from database.

    Lets take an example: you might have a class called Person, a class called Account and a class called Group. Each person would own one Account and they would have the possibility of belonging to many groups. This is a very simple example and you could write all the necessary methods by hand (retrieving all persons and their accounts, saving person's account etc.) or you can skip this phase (which in big projects can be very big phase) and use one of the availible ORM tools like (EZPDO, Propel or Doctrine). Personally I would recommend Doctrine although as its creator my opinion is clearly biased

    PHP Code:
    class Person extends Doctrine_Record {
      public function 
    setTableDefinition() {
        
    $this->hasColumn("name","string",200);
      }
      public function 
    setUp() {
        
    $this->hasMany("Person","GroupPerson.person_id");
        
    $this->ownsOne("Account","Account.person_id");
      }
    }
    class 
    Account extends Doctrine_Record 
      public function 
    setTableDefinition() {
        
    $this->hasColumn("amount","integer",11);
        
    $this->hasColumn("person_id","integer",11);
      }
    }
    class 
    Group extends Doctrine_Record {
      public function 
    setTableDefinition() {
        
    $this->hasColumn("name","string",200);
      }
      public function 
    setUp() {
        
    $this->hasMany("Person","GroupPerson.person_id");
      }
    }
    class 
    GroupPerson extends Doctrine_Record {
      public function 
    setTableDefinition() {
        
    $this->hasColumn("group_id","integer",11);
        
    $this->hasColumn("person_id","integer",11);
      }
    }

    // USAGE:

    $person = new Person();
    $person->name "JustMe";
    $person->Account->amount 1000;
    $person->save(); 
    /** executes two prepared queries and wraps them into transaction the 
      *  queries would look like: INSERT INTO person (name) VALUES (?)
      * INSERT INTO account (person_id, amount) VALUES (?,?)
      */

    // retrieve all persons and accounts ($session is Doctrine_Session object):

    $persons $session->query("FROM Person.Account"); 

  15. #15
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zYne
    class Person extends Doctrine_Record
    I'd suggest you to use composition here, not inheritance...

  16. #16
    is_empty(2); foofoonet's Avatar
    Join Date
    Mar 2006
    Posts
    1,000
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @zYne. Oh my. Doctrine ...isn't that the first ORM tool to be built on PDO?
    Upgrading to Mysql 5? Auto-increment fields now strict
    use NULL
    Or zero or leave the field name out completely.

  17. #17
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm propably the first ambitious ORM framework to be built on PDO. I think there where some very simple activerecord solutions before it that where also built on PDO.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •