PHP Classes

File: Docs/Database.txt

Recommend this page to a friend!
  Classes of Minh Tien   Codeme PHP Framework   Docs/Database.txt   Download  
File: Docs/Database.txt
Role: Documentation
Content type: text/plain
Description: Documentation
Class: Codeme PHP Framework
MVC Web application development framework
Author: By
Last change: Update of Docs/Database.txt
Date: 5 months ago
Size: 1,283 bytes
 

Contents

Class file image Download
//Connect to database Database::connect(); //Connect to another db Database::connect('custom-name'); //Make a query $query=Database::query("select * from table_name"); //Work with anonymous function $query=Database::query("select * from table_name",function($query){ $dataRows=Database::fetch_assoc($query); }); //Get numrows $numRows=Database::num_rows($query); //Work with anonymous function $numRows=Database::num_rows($query,function($result){ if((int)$result == 0) { //do something } }); //Fetch assoc $dataRow=Database:fetch_assoc($query); //Work with anonymous function $dataRow=Database:fetch_assoc($query,function($result){ print_r($result); }); //Get insert id $id=Database::insert_id(); //Work with anonymous function Database::insert_id(function($result){ echo $result; }); //Insert with ORM $user = new DatabaseORM('users'); $user->username = 'test'; $user->password = md5('demodemo'); $id=$user->InsertOnSubmit(); echo $id; //Update with ORM $user = new DatabaseORM('users'); $user->where('userid',30)->where('fullname','safeservicejt'); $user->username = 'testtest'; $user->password = md5('fgfg'); $user->SubmitChanges(); //Delete with ORM $user = new DatabaseORM('users'); $user->where('userid',30); $user->DeleteOnSubmit();