PHP Classes

classMySQL: A simple class to access MySQL Databases

Recommend this page to a friend!
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 41%Total: 5,425 All time: 471 This week: 144Up
Version License Categories
classmysql 1.0GNU General Publi...Databases


This class is intended to simplify the access to MySQL Databases. In a complex application, you should need only one instance of the class making it global.

Picture of Daniel Andres Marjos
  Performance   Level  
Name: Daniel Andres Marjos is available for providing paid consulting. Contact Daniel Andres Marjos .
Classes: 13 packages by
Country: Argentina Argentina
Age: 53
All time rank: 261 in Argentina Argentina
Week rank: 101 Down1 in Argentina Argentina Equal
Innovation award
Innovation award
Nominee: 2x


The db_mysql is based in a superclass (db_layout) which will be the base for other database implementations. The properties of db_MySql are: $db_result: Internal. It holds the result of a query $db_affected_rows: It holds how many records (row) were affected by the last query $saved_results: Internal. An array with the results Used by PushResults and PopReslts (see below) $results_saved: Internal. An index pointer. The Methods: error(string [where],string error,string errno) : This is an internal function. It halts the script execution upon error error_msg(): Returns the last MySql error. PushResults(): Saves the last operation result in the internal stack. Used to keep track of the operations in a single instance of the class. PopResults(): Retrieves de las result in the stack. db_mysql(string host, string user, string passwd, string db, string [create]): The class Constructor. The create parameter is a flag that indicates if the class should attempt to create the database if it doesn't exists. reselect_db(string db): Internal. Used tu rebuild the internal database handler to the specified database. closeDB(): Closes the database. create_table(string tblName,mixed tblStruct) Tries to create the table. tblStruct can be a string or an array,. The format of the array if plain. No keys are precessed and each element should represent a mysql field definition. drop_table(string tblName): Drops a table. raw_query(string sql_stat): This is a function that allows a raw query. Useful to perform a migration from old applications that doesn't use a class. count_records(string table,string [filter]): returns how many records meets the condition specified in filter select(string fields,string tables,string [where], string [order_by], string [group_by],string [having], string [limit]): Allows to select records. list_tables(): returns the tables in the database tablename(resource tables, int tbl) Retrieves the name of table tbl insert_id(): the autoincrement value of the last insert. insert(string table,mixed [fields], mixed [values]): Inserts a record in the table. the parameters fields and values can be comma delimited strings or arrays update(string table,string newvals,string [where]): Updates a table delete(string table,string [where]): deletes records free(): dispose the last mysql result. fetch_row(): returns an array with keys [0]...[n] with each field in the resultset result(int recno,string field): returns the content of the field in record recno num_fields(): returns how many fields are in the resultset fetch_array(): returns an array in the format [fname]=value fetch_field(): returns the next field --------------- This class was intended to encapsulate the mysql_* functions.

  Files folder image Files  
File Role Description
Plain text file classMySQL.php Class The class
Accessible without login Plain text file readme.txt Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:471
This week:144Up
 User Ratings  
 All time