Login   Register  
PHP Classes
elePHPant
Icontem

File: README

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Carsten Gehling  >  sql_Generator  >  README  >  Download  
File: README
Role: Documentation
Content type: text/plain
Description: Class documentation
Class: sql_Generator
Class used to ease generation of SQL queries
Author: By
Last change:
Date: 11 years ago
Size: 3,250 bytes
 

Contents

Class file image Download
Project: sql_Generator
Version: 0.9
Author: Carsten Gehling (carsten@sarum.dk)
Date: 2003-07-29

About this file
----------------
This is the documentation for sql_Generator. The example files pretty much
explains everything however.

If you have any questions regarding the use of sql_Generator or suggestions
for this README file, please contact me at carsten@sarum.dk. I will
get back to you as soon as possible.

TODO:
------
This class is made specifically for MySQL. I would like to make it functional
for other DBMS including their little quirks.

sql_Generator
---------------
The class sql_Generator is used to automatically generate either insert or
update sql statements based on the same set of fields.

For a complete example, please refer to the files:
    example1.php
    example2.php

Here follows a description of the public interface:

function sql_Generator($tablename = "")
-----------------------------------------
This is constructor for the object.

Parameters:
    tablename: The name of the table that is to be used in the sql statement


function create($tablename)
-----------------------------
Resets the class to make a new sql statement on another table

Parameters:
    tablename: The name of the table that is to be used in the sql statement


function addField($key, $value, $type = "string")
---------------------------------------------------
This function should be called for every field that you want
to insert/update in the record.

Parameters:
    key:   The name of the field
    value: The new value of the field
    type:  How should the field be represented in the sql statement?
           Values can be "string", "number" or "function"; default is "string".
           "string" can be used in most cases, since MySQL accepts apostrofs around
           any value except function calls.


function makeInsert()
-----------------------
This function returns a sql statement for inserting records in the table.
Returns "" if the class has not been supplied with a tablename and/or fields.

Parameters:
    None


function makeUpdateKey($key, $value, $type = "string")
--------------------------------------------------------
This function returns a sql statement for updating records in the table
given a field description to identify the record.
Returns "" if the class has not been supplied with a tablename and/or fields.

Parameters:
    key:   The name of the field
    value: The value to use for identifying the record.
    type:  How should the field be represented in the sql statement?
           Values can be "string", "number" or "function"; default is "string".
           "string" can be used in most cases, since MySQL accepts apostrofs around
           any value except function calls.


function makeUpdateKey($key, $value, $type = "string")
--------------------------------------------------------
This function returns a sql statement for updating records in the table
given a where expression.
Returns "" if the class has not been supplied with a tablename and/or fields.

Parameters:
    whereexpr: An expression like "age < 21". The keyword "where" is automatically
               added.