Gumbo_Interface_Query



Query Interface

This interface was designed to create a common class for a program to execute database queries (select,insert,update,delete). By using a common interface, any changes made to the database engine (PDO, ADODB, PEAR_DB, etc) can be reflected in a Query class, and not the entire program. For example, if a program is written for PEAR_DB, but a decision was made to switch to PDO, the transition is made much easier when the implementation is in one location. Imagine having to search through thousands of lines of code and change the implementation from PEAR_DB to PDO.

Author(s): Michael Luster <mluster79@yahoo.com>
License:New BSD License
Copyright:Copyright (c) 2007, iBayou, Michael Luster
Link:http://sourceforge.net/projects/phpgumbo
Version:0.0.1

Interface Methods

public static mixed execute ( string $sql, [array $params], [string $name] ) [line 67]

Executes the given query and returns the results

This is a Bridge between the DB interface and the Item class. It will execute a sinle query and return the results. If a SELECT is performed, then a single associative array representing a record is returned. If an INSERT is performed, then the new insert ID is returned. UPDATE and DELETE queries will not return anything.

Parameter(s):

  • (string) $sql
  • (array) $params :: list of parameters for the prepare method
  • (string) $name :: sequence/column name for returning lastInsertId()

[ Top ]
public static string prepare ( string $sql, [array $params], [string $token] ) [line 76]

Prepares a query by substituting a token character with parameter values

Parameter(s):

  • (string) $sql
  • (array) $params :: list of parameters
  • (string) $token :: replacement token character

[ Top ]
public static array results ( string $sql, [array $params] ) [line 51]

Returns an array of Items with the results of a "SELECT ... " query

Parameter(s):

  • (string) $sql :: query to execute
  • (array) $params :: token parameter values

[ Top ]