Recommend this page to a friend! |
Download .zip |
Info | View files (6) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2003-07-29 (13 years ago) | Not enough user ratings | Total: 878 | All time: 3,834 This week: 1,081 |
Version | License | Categories | ||||
sql_generator 1.0 | GNU Lesser Genera... | Databases |
Description | Author | |||||||||||||
This class is meant to make it easier to generate SQL queries for inserting or updating records in a database table. |
|
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. |
Files |
File | Role | Description |
---|---|---|
class_sql_generator.php | Class | Main class file |
COPYING | Lic. | LGPL License |
example1.php | Example | Example on how to use the class |
example2.php | Example | Example on how to use the class |
LICENSE | Lic. | Personal license information |
README | Doc. | Class documentation |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
0% |
|
|