PHP Classes

CM SQL: Execute SQL queries and format results

Recommend this page to a friend!
  Info   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStar 32%Total: 740 All time: 4,525 This week: 488Up
Version License Categories
cm_sql 1.0GNU General Publi...Databases


This is a simple package meant to execute SQL SELECT queries and format the query results.

The select class can connect to the database server, execute SELECT queries and store the results in an array class variable. The database connection can be configured by an external script.

A separate string formatting class can be use format the values returned as query results.

Currently it only supports MySQL but support for other SQL databases, like PostgreSQL and Oracle, is planned for a future release.

Picture of Maurice Courtois
Name: Maurice Courtois <contact>
Classes: 2 packages by
Country: United States United States
Age: 43
All time rank: 67789 in United States United States
Week rank: 286 Up29 in United States United States Up


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,, : 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 You also need to flush the containt of the buffer at the end of each script ob_end_flush() : : 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. : 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 folder image Files  
File Role Description
Accessible without login Plain text file AUTHORS Data AUTHORS file
Accessible without login Plain text file CHANGELOG Data CHANGELOG
Accessible without login Plain text file Aux. Connection function script
Accessible without login Plain text file Conf. Environment variable for the class
Accessible without login Plain text file GPL.txt Lic. License
Accessible without login Plain text file README Doc. Readme
Plain text file Class The SQL class file

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:4,525
This week:488Up
 User Ratings  
 All time