| Login | Register | |||
| Recommend this page to a friend! |
| Classes of JImmy Bo | > | Bobo PHP DB Class | > | Download | > | > | > | |||||
|
|||||||||||||||||||||||
| Author | Detailed description | |||||
| Applications | ||||||
Author
Groups
Detailed descriptionThis class simplifies connections to a MySQL database.
Connections are automatically created if they are not already connected on the first query (meaning a connect statement is not required). The class can also retrieve the identifier of the last inserted record, and check whether a given table exists. A query can return data into an array, a single variable, or just return the id of the last insert (get,row,q respectively). Script can manually be told to open or close the connection (connect or close respectively). More information on how to use this class is available in the class source code. * example usage: * * 1) create a file called inc.config.php in it throw this: * // include the class: * include_once('class.db.php'); * // set the variables: * $db_host = "localhost"; * $db_user = "myusername"; * $db_pass = "mypassword"; * $db_name = "mydatabasename"; * // make a db object: * $db = new mydb($db_host, $db_user, $db_pass, $db_name); * * 2) now in your file that you want to access the db from just include_once('inc.config.php'); * don't worry it won't connect till it's first query and it does so automagically. * * 3) some example usage: * // an insert * $SQL = "INSERT INTO addressbook (name) VALUES ('bob')"; * $insertid = $db->q($SQL); // returns false if no insertid or the id * echo $insertid; * * // a single row returned * $SQL = "SELECT * FROM addressbook WHERE name LIKE 'bob' LIMIT 1"; * $row = $db->row($SQL); * echo $row['name']; * * // multiple rows returned * $SQL = "SELECT * FROM addressbook"; * $addresses = $db->get($SQL); * foreach($addresses AS $address) * echo $address['name']; * * // prematurely open * $db->connect(); * // prematurely close * $db->close(); // will reopen automatically if needed again * latest version: * - changed safe text so it uses proper mysql function * - added function error to store errors * - added function show_errors to display the errors * - added function update_array (example at bottom of this script) * - added function insert_array (example at bottom of this script) User ratings
Applications that use this classNo application links were specified for this class.
Files
|
| Copyright (c) Icontem 1999-2009 | PHP Classes | - PHP Class Scripts |
| PHP Book Reviews | - Reviews of books and other products |