query interface

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
zyklone
Forum Commoner
Posts: 29
Joined: Tue Nov 28, 2006 10:25 pm

query interface

Post by zyklone »

I want to create my own query abstraction. is it best way to do:

Code: Select all

interface Sql
{
     public function query($sql) {}
     public function fetch_array($result) {}
     ... etc ...
}

class Mysql implements Sql
{
   public function query($sql)
   {
        ... implementation...
    }

    public function fetch_array($result)
    {
         ... implementation... 
    }
}

class Mssql implements SQL
{
    ....etc....
}
is that the best way to to?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

There is another thread looking into creating a similar class:

viewtopic.php?t=69653&highlight=

You might want to combine efforts and find the past threads that have covered this topic.
(#10850)
Post Reply