Version: 1.2
Type: Class
Category: Databases
License: GNU General Public License
Description: MCI will help manage mysql database common task, Its flexibility can manage big application by adding subclasses depend on your needs.
<?php /** * @Mysql Class Interface (MCI) - PHP4/5-compatible * @created 2007/11/27 by Robert L Concha of Scinettek Group * @Note: You can add more subclasses for fetch array, delete, etc... * Usage Example: * <?php * $static =& new Connect ('localhost','root','root','robert'); * * $Select=new Controller('Select'); * $Select->exe(SELECT * FROM table .....,$static); * $Insert=new Controller('Insert'); * $Insert->exe(INSERT INTO table ......,$static); * $Update=new Controller('Update'); * $Update->exe(UPDATE table SET .....,$static); * ?> */ class Connect { /** * @var db for * connect class */ var $db; // __constructor function Connect ($host,$user,$pass,$db) { $this->db=mysql_pconnect($host,$user,$pass); mysql_select_db($db,$this->db); } } class Select { // subclass query mysql using // select function exe($sql) { $exe = mysql_query($sql); return $exe; } } class Insert { // subclass query mysql using // insert function exe($sql) { $exe = mysql_query($sql); return $exe; } } class Update { // subclass query mysql using // update function exe($sql) { $exe = mysql_query($sql); return $exe; } } // You can define more subclasses here for fetch array, // delete, Join etc.. class Controller { /** * var: control * for module */ var $control; /** * class contructor */ // load the subclass function Controller($control) { eval("$this->control = new $control;"); } function exe($sql) { $this->control->exe($sql,$db); } } ?>