MySqlDB Class |
constructor | public | _private |
Public :: MySqlDB |
Parent Class:
Subclasses:
|
Class to access a database on a MySql server. // create a new sqldb object - Database host, Database user, Database pass, use logger class $sqldb = new MySqlDB("dbhost","dbuser","dbpass",true); // select a database $sqldb->selectDB("myFirstDB"); // now turn debug messages for all queries to "myFirstDB" on $sqldb->setDebugMode(TRUE); // and select some data $result = $sqldb->select("*","firstTable","col1 = 'test'"); |
constructor | |
MySqlDB object | = MySqlDB(STRING $server, STRING $user, STRING $password, BOOL $use_log) |
create a new MySqlDB object and connect to database server | |
public methods | |
RESOURCE IDENTIFIER | = MySqlDB->del(STRING $table, STRING $filter); |
delete from given table using the filter in the WHERE clause, i.e. MySqlDB->del("someTable","idColumn > 100"); | |
RESOURCE IDENTIFIER | = MySqlDB->emptyTable(STRING $table); |
empty a complete table and reset AUTO_INCREMENT columns, i.e. MySqlDB->emptyTable("someTable"); | |
STRING | = MySqlDB->getName(); |
get name of database currently connected to | |
RESOURCE IDENTIFIER | = MySqlDB->insert(STRING $table, STRING||ARRAY $cols, STRING $vals); |
insert data into the specified table, i.e. MySqlDB->insert("someTable","col1, col2", "val1, 'val2'"); This method can also receive an associative array [with column_name as key and column_value as value] as second argument. | |
RESOURCE IDENTIFIER | = MySqlDB->listTables(); |
get a list of all tables accessible by the current user in the current database | |
RESOURCE IDENTIFIER | = MySqlDB->select(STRING $what, STRING $table, STRING $filter, STRING $order); |
select data from table(s), i.e. MySqlDB->select("*","someTable as sT, anotherTable as aT","someColumn LIKE '%test%'","someColumn"); | |
MySqlTable Object Reference | = MySqlDB->selectTable(STRING $table); |
select the specified table and receive a corresponding MySqlTable object | |
RESOURCE IDENTIFIER | = MySqlDB->update(STRING $table, STRING||ARRAY $cols_vals, STRING $filter); |
update data in the specified table, i.e. MySqlDB->update("someTable","someColumn = 'someValue', anotherColumn = 10","someColumn = 'update'"); Like the insert method, this method can receive an associative array [with column_name as key and column_value as value] as second argument. |
|
inherited methods | |
see MySql Baseclass | |