Mysql Done Right

A PHP class for MySQLi utilizing prepared queries
Download

Mysql Done Right Ranking & Summary

Advertisement

  • Rating:
  • License:
  • LGPL
  • Price:
  • FREE
  • Publisher Name:
  • Daren Schwenke
  • Publisher web site:

Mysql Done Right Tags


Mysql Done Right Description

A PHP class for MySQLi utilizing prepared queries Mysql Done Right is a PHP5.0+ class which provides a SAFE, clean, object oriented, and efficient way to do MySQL database development.All queries except those with multiple row results return exactly what you need in ONE LINE OF CODE.This is all done while still maintaining use of prepared queries and bound parameters to eliminate the risk of SQL injection attacks and operate more efficiently.No extra coding is needed on your part to reuse prepared queries. You simply write the same query again, and if you have done that one before, the prepared handle is reused. The newly bound parameters are used against the existing prepared handle, and the results are recomputed. The results themselves are not cached.So there you have it. Simple use of prepared queries with bound parameters, while still having access to the fetch_object and fetch_assoc methods. Now you have no excuse.USAGE:See examples.php for database connection setup details.General format for all queries: $db->method_name('MySQL query with ? substituted for variables','corresponding placeholder types',corresponding variables for placeholders);That format explained:SQL queries themselves are beyond the scope of this document. Common examples are below.Placeholders are allowed to be these types. Straight from http://php.net/manual/en/mysqli-stmt.bind-param.php i corresponding variable has type integer d corresponding variable has type double s corresponding variable has type string b corresponding variable is a blob and will be sent in packets Sending data of type blob or text is currently limited to the size of max_allowed_packet.Variables to assign to each type. Should be scalars.EXAMPLES:Inserts return insert ID:$insert_id = $db->pinsert('INSERT INTO sometable (somestring,someint,somedouble,someblob) VALUES (?,?,?,?)','sidb',$string,$int,$double,$blob);Updates return count of rows affected:$rows_affected = $db->pexecute('UPDATE sometable SET somestring = ? WHERE someint = ? LIMIT 1','si',$string,$int);Deletes return count of rows affected:$rows_affected = $db->pexecute('DELETE FROM sometable WHERE someint = ? LIMIT 1','i',$int);Just count rows return without reading the data:$row_returned = $db->prows('SELECT something FROM sometable WHERE somestring = ? AND someint >= ?', 'si' , $string,$int );Select a single row and return an object containing the data.$obj = $db->psingle('SELECT someint,somestring FROM sometable WHERE someint = ? LIMIT 1','i',$int);print $obj->someint; print $obj->somestring;Select multiple rows and return a handle.$some_sth = $db->pbind('SELECT somestring FROM sometable WHERE someint = ?','i',$int);while ( $row = $some_sth->fetch_object() ) { print $row->somestring; }$some_sth->close(); Requirements: · PHP What's New in This Release: · The license has been changed to LGPL and the documentation was updated.


Mysql Done Right Related Software