SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question PDO or SQLite Functions?

    Hi,

    Can you please tell me whether it's better to use SQLite functions (http://ca.php.net/manual/en/ref.sqlite.php) or PDO functions (http://www.litewebsite.com/?c=49#sqlite3).

    Please advise. Thanks.
    Why It Doesn't Work?!

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'd say PDO.

    This is because you can simply change the DSN String to connect to another database, and you wouldn't need to change any more code.

    That is, of course, if you use queries and methods that work with both drivers.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm 100% sure I'll not use other than SQLite.

    Should I use SQLite functions in that case? If so, any idea when SQLite3 will be supported?

    Thanks.
    Why It Doesn't Work?!

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    There are only two things to be 100% sure about - death and taxes.

    If you are positive that you'll never need a more powerful engine, sure the SQLite functions could be used, but I'd still use PDO.

    That's because PDO has prepared statements - which are fantastic for security and speed reasons.

    A prepared statement is where the driver sends MySQL/SQLite a version of the query but with placeholders rather than actual values. MySQL /SQLite then sorts out exactly how it's going to run the query, and PDO then sends the values. This is the same speed as a usual query with one query, but when using the same query for different data say 10 times, it's about 8 times faster than running 10 individual queries

    For example:
    PHP Code:
    <?php
    $q 
    $database->prepare("INSERT INTO squares (base, value) VALUES (:i, :j)");
    $i 1;
    $j 1;
    $q->bindParam(':i'$iPDO::PARAM_INT);
    $q->bindParam(':j'$jPDO::PARAM_INT);
    for(; 
    $i 100$i++){
        
    $j pow($i2);
        
    $q->execute();
    }
    It also means that you don't need to escape data because it isn't inserted directly into the query.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    All right, I'll use PDO.


    Thanks
    Why It Doesn't Work?!

  6. #6
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use PDO I am using it for one of my projects and it makes it very easy to switch database types.
    Have a good day.

  7. #7
    SitePoint Guru risoknop's Avatar
    Join Date
    Feb 2008
    Location
    end($world)
    Posts
    834
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes listen to arkinstall. PDO is good. I have just switched from MySQLi to PDO and I haven't noticed any problems or performance issues. It is true that PDO doesn't offer as many options as other extensions but it is very portable and has 90&#37; of stuff.

  8. #8
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The reason it doesn't offer as much is because it can't - thanks to incompatibilities with other drivers.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


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
  •