Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Location
    India
    Posts
    109

    Unanswered: Designing a generic database API

    Hi,

    My current project requires me to convert a mysql based software to a more generic one. I started by designing separate db class files and separated the lower level connection queries from the business logic. By doing this, I now have mssql.class, mysql.class, sqllite.class etc..

    But am not sure how to handle sql functions in queries. For instance, one of my queries need the use of a date function to add minutes to a db field.

    In mysql, I accomplish this using

    dbfield+interval '$arg' minute between date1 and date1


    But in mssql I cannot use this type of query. It seems I'll have to use date_add() function. How do I handle this situation?

    My frontend scripting language is php

    Thanks d'advance
    Celia

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I would create a function in your PHP code that takes two arguments, a "date" and an "adder" to the date. That way you can "cook" them as needed for each database engine, while keeping the PHP quite generic.

    -PatP

Posting Permissions

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