SQL Query Builder iconSQL Query Builder 1.2

SQL Query Builder is a PHP 5 class that generates simple SQL queries.
SQL Query Builder is a PHP 5 class that generates simple SQL queries (select, insert, update, and delete) that can be sent to an SQL server.

It provides an intuitive class-based way to build queries instead of crafting complicated one-line or concatenated-string queries by hand.

It is very useful for dynamic queries, and is appropriate for AJAX applications. SQL Query Builder project also features simple and optional error reporting.

Function reference

void __construct ( string queryType )

This function sets the query type to build. This can be "select", "insert", "update", "delete" or "query" It is not case-sensitive.
The type "query" indicates that an arbitrary provided query will be returned, such as "CREATE ...", "DROP ...", etc.
See setQuery()

void setTable ( string tableName )

This function sets the table name to work on.

void addColumn ( string colName )

This function adds one column to the list of columns that will be affected by the query.

void SetValue ( string value )

This function adds one value corresponding to it's column name, be sure to assign the column names in the same position as the values. The first column you add must be the first value you add.

For flexibility reasons. this function doesn't add slashes or any escaping, that is your work!

void setWhere ( string where )

This function sets the WHERE clause (i.e. earnings < 1000)

void setGroupBy ( string groupBy )

This function sets the GROUP BY clause

void setHaving ( string havong )

This function sets the HAVING clause

void setOrderBy ( string orderBy )

This function sets the ORDER BYclause

void setLimit ( string limit )

This function sets the LIMIT clause

void setQuery ( string query )

This function sets the query that will be returned if query type "query" is selected when creating the object

void showErrors ( bool $showErrors )

With this function you can set whether to print errors or not. Usefull for debugging (default is true)

void buildQuery ( void )

If no data is missing for the selected query type, this function will return the built query as a string, otherwise, if showErrors() is set to true (by default) it will print the error message.

last updated on:
January 9th, 2006, 17:54 GMT
developed by:
David Regla Demaree
license type:
Other/Proprietary License with Source
ROOT \ Utilities


In a hurry? Add it to your Download Basket!

user rating 2



Add your review!