Recommend this page to a friend! |
Download .zip |
Info | View files (7) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2004-11-19 (11 years ago) | 32% | Total: 737 | All time: 4,339 This week: 1,042 |
Version | License | Categories | ||||
cm_sql 1.0 | GNU General Publi... | Databases |
Description | Author | |||||||||||||
This is a simple package meant to execute SQL SELECT queries and format the query results. |
|
cm sql version 0.1 Copyright Cnet com @ 2004 This package has been developed to simplify the use of databases. Currently we only support MySQL but we planned to support another SQL servers (PostgresSQL, Oracle) in mid 2005. Requirement in your script : require environment.inc, connection.inc, SQL.inc environment.inc : This file contained all the necessary variables and the error function when SQL failed. You absolutely need to personalissed this file for your environment. Change de $db and $host var to reflect your local setting. Notice : You can make query on more than one database, the $db var is only here to have a default database to connect to (if you don't pass a $db argument to the select object). You also need to use the function ob_start(); on all your script, see http://ca.php.net/manual/en/function.ob-start.php. You also need to flush the containt of the buffer at the end of each script ob_end_flush() : http://ca.php.net/manual/en/function.ob-end-flush.php connection.inc : This file contained the connection function. Copy the connect_example() and change the information for each connection you need. You need to create a function connection for every user your need to use to connect to the database. Later we will change completely the function connection to support more than one type of SQL database, if you upgrade to another cm_sql version please check the ChangeLog to know any change about this. SQL.inc : This file is the sql class to make your query. How it work ? An example for doing a select, insert, delete or anything else. $store_res = new select("QUERY TO EXECUTE", "CONNECTION FUNCTION (connect_example())", "The database to connect (default is $GLOBALS['db'])"); An example $query = "SELECT * FROM test"; $store_res = new select($query, "connect_example()"); You need to put the connection function into double quote and you have to called them exactly what is shown before. After that you have an array : $store_res->result containing the result of your query. Bellow is an example to extract the data. for($i=0; $i<count($store_res->result); $i++) { # Each row for($j=0; $j<count($store_res->result[$i]); $j++) { # Each cell echo $store_res->result[$i][$j]; } echo "\n<BR>"; } |
Files |
File | Role | Description |
---|---|---|
AUTHORS | Data | AUTHORS file |
CHANGELOG | Data | CHANGELOG |
connection.inc | Aux. | Connection function script |
environment.inc | Conf. | Environment variable for the class |
GPL.txt | Lic. | License |
README | Doc. | Readme |
SQL.inc | Class | The SQL class file |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
0% |
|
|
User Ratings | ||||||||||||||||||||||||||||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.