/*
* Author: Rafael Rocha - www.rafaelrocha.net - http://projects.rafaelrocha.net/ - info@rafaelrocha.net or rafael_xl1@hotmail.com for any question - EN and PT
*
* Date: 26.04.2009
*
* Version: 1.1
*
* License: LGPL
*
* What do: This is a class to convert your mysql
* tables into php classes.
*
*/
Indice
I-What do?
II - Install
III - How to use functions
IV - About author
V - Bugs Fixed and Other important things
I - What this class do?***************************
Run index.php, set the mysql connection settings. This will be convert all your tables into php classes.
For exemple you have table: Users, Products. You will have users.class.php and products.class.php. With
getters and setters and other nice functions. Any question info@rafaelrocha.net.
II - Install ***************************
Just run index.php and put in the Textfields mysql information. Make sure that file directory is 777CHMOD.
III - How to use functions ***************************
After you have all of your classes put them into library folder FOR EXAMPLE: (just a example)
library/users.class.php
products.class.php
public_html/index.php
in public_html/index.php use:
require '../users.class.php';
require '../products.class.php';
Now you can use!
$Classe_user = new users(); // use to connect to mysqli with class DataBaseMysql.class.php
//Load user id=4 *******
$Classe_user->Load_from_key(4);
//OK! now you can use that by getfunction. You can have all information in ROW id=4!
echo $Classe_user->getName();
echo $Classe_user->getPassword();
//Construct*******
$Classe_user->New_user("Rafael", "pasword"); //you had clear by reload new information into variable
$Classe_user->Save_Active_Row_as_New(); // save this new user as a new in table
//Set Function ANd Save_active_row() *******
$Classe_user->Load_from_key(4); //all information about id=4
$Classe_user->setName = ("John"); // Rafael -> John (same password yet!)
$Classe_user->Save_Active_Row(); // UPDATE row in table
//Delete_row_from_key($key_row){} *******
$Classe_user->Delete_row_from_key(4); //delete row that have id=4.
//GetKeysOrderBy($column, $order) *******
$keys = $Classe_user->GetKeysOrderBy("name", "desc"); // array of keys order by name desc. You can put asc
for($i=0; $i!=sizeof($keys); $i++){ run all the array
$Classe_user->Load_from_key($keys[$i]); // possicion in key array, to load information
echo $Classe_user->name; //right information, with orther by name desc.
}
//you see that just a simple for and array off keys, you can have all users information simplY!!!
IV - About Author **********************
Rafael Rocha is from Póvoa de Santo Adrião > Odivelas > Lisboa > Portugal
Study in ISCTE LISBON engº informatica
info@rafaelrocha.net or rafael_xl1@hotmail.com for any question - EN and PT
www.rafaelrocha.net
http://projects.rafaelrocha.net/ -> to libraries
V - Bugs fixed and other important things
* Bugs fixed in 1.1:
* 1º Mysqli query function
* 2º Save as new function on classes
* Bugs still hapen:
* 1º table keys in end of table missing. So don´t let your table keys in end of table fields
IMPORTANT: This classe use mysqli classe, that just php 5.0 have! if you don´t have mysqli function, you need to install manual.
|