Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage
Php > Database Related sample source codes
MySQL Command
MySQL Command // Base SQL command class for MySQL operations class mysql_command { // Init variables required VAR $connobj = "" ; VAR $sqlstring = "" ; // Data related variables VAR $rs ; VAR $recordcount = 0 ; VAR $EOF = true ; VAR $lastid = 0 ; // Private methods function exec_command() { if ($GLOBALS[$this->connobj]->db && $this->sqlstring!="") { $this->rs = mysql_query($this->sqlstring,$GLOBALS[$this->connobj]->db) ; $GLOBALS[$this->connobj]->error_level = mysql_errno() ; $GLOBALS[$this->connobj]->error_desc = mysql_error() ; if ($this->rs) { $this->EOF = true ; $this->recordcount = mysql_affected_rows() ; $this->lastid = mysql_insert_id() ; $GLOBALS[$this->connobj]->msg = "\r\n" . date("d/m/Y - H:i:s") . " - OPERATION O.K.: Executed " . $this->sqlstring ." affected " . $this->recordcount . " rows" ; } else { $this->recordcount = 0 ; $this->EOF = true ; $GLOBALS[$this->connobj]->msg = "\r\n" . date("d/m/Y - H:i:s") . " - OPERATION FAILED: Executed " . $this->sqlstring . " got " . mysql_errno() . " " . mysql_error() ; } } else { $this->recordcount = 0 ; $this->EOF = true ; $GLOBALS[$this->connobj]->msg = "\r\n" . date("d/m/Y - H:i:s") . " - OPERATION FAILED: No database open OR no SQL command provided" ; } $GLOBALS[$this->connobj]->debug() ; } // Public interface function execute() { $this->exec_command() ; return $this->recordcount ; } function mysql_command($connobjname,$sqlcommand) { $this->connobj = $connobjname ; $this->sqlstring = $sqlcommand ; } } ?>
Privacy Policy
|
Link to Us
|
Links