Login   Register  
PHP Classes

File: MysqlMQ.class.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Gilton Guma  >  MySQL Multi Query  >  MysqlMQ.class.php  >  Download  
File: MysqlMQ.class.php
Role: Class source
Content type: text/plain
Description: MysqlMQ.class
Class: MySQL Multi Query
Execute multiple MySQL queries at a time
Author: By
Last change: Log 1.0.1:
- Adjusted the attribute "sql" to array[] in class, to fix the bug with the semicolon.
- Users of version 1.0.0 should adjust the calls, see examples.

Sorry my English! :)
Date: 3 years ago
Size: 2,144 bytes


Class file image Download
  MysqlMQ - Simple Class Mysql Multi Query
  @author    Gilton Guma
  @version   1.0.1
  @warning   Works only tables with InnoDB Storage Engine
  @param sql {string} Multiple Query
  @param aft {string} Text after error
  @param bef {string} Text before error
  @param srv {string} Server name of conection
  @param usr {string} User name of conection
  @param pwd {string} Password of conection
  @param dtb {string} Database of conection
class MysqlMQ {
private $err//Error's
private $aft//After error
private $bef//Before error
private $srv//Server name
private $usr//User name
private $pwd//Password
private $dtb//Database
function MysqlMQ(){
$this->sql = array();
$this->err NULL;
$this->aft "<strong>Error:</strong> ";
$this->bef "<br />";
$this->srv "localhost";
$this->usr "root";
$this->pwd "";
$this->dtb "";
//Settings atribute of class
function setSQL($value){ $this->sql[] = $value; }
setAft($value){ $this->aft   $value; }
setBef($value){ $this->bef   $value; }
setSrv($value){ $this->srv   $value; }
setUsr($value){ $this->usr   $value; }
setPwd($value){ $this->pwd   $value; }
setDtb($value){ $this->dtb   $value; }
//Get attributes values of class
function getSQL(){ return $this->sql; }
getErr(){ return $this->err; }

    Execute multiple queries to the database
    @return true|false {boolean}
function mQuery(){
$er false//Erro

$db = new mysqli($this->srv$this->usr$this->pwd$this->dtb);

    if (@
mysqli_connect_errno()) return false;


    foreach (
$this->sql AS $ss){
      if (
        if (!
$er true;
$this->err.= $this->aft.$db->error.$this->bef;

$er $db->rollback() : $db->commit();


    return !