Nota: Para poder utilizar las clases de alli arriba, deben utilizar una para MySQL que yo mismo he hecho... Si despues quiren pueden adaptarlo a la suya... Pero el codigo fue hecho con la utilizacion de la siguiente clase para MySQL... Bien "Simple".
SimpleMySQL.php
Código PHP:
Ver original<?php
/**
* @copyright 2009
*/
/**
* MySQL Management Class
*
* @author Diego P. M. Baltar <www.estilodg.com>
* @package SimpleMySQL
*/
class SimpleMySQL
{
/**
* Link identifier
*
* @access public
* @var resource
*/
public $link = null;
/**
* Selected database
*
* @access public
* @var string
*/
public $database = null;
/**
* Query result resource
*
* @access public
* @var resource
*/
public $result = null;
/**
* Query result data
*
* @access public
* @var array
*/
public $query_result = array();
/**
* Query error
*
* @access public
* @var boolean
*/
public $query_error = false;
/**
* Selected rows
*
* @access public
* @var integer
*/
public $rows = null;
/**
* Number of affected rows
*
* @access public
* @var integer
*/
public $affected_rows = null;
/**
* Last inserted id
*
* @access public
* @var integer
*/
public $last_id = null;
/**
* MySQL connection state
*
* @access public
* @var boolean
*/
public $ready = false;
/**
* Database tables
*/
public $tables = array();
public function __construct($hostname = 'localhost', $username = 'root', $password = '')
{
return $this->connect($hostname, $username, $password);
}
public function __destruct()
{
return true;
}
/**
* MySQL connect
*
* @param string $hostname MySQL server address/ip(port)
* @param string $username MySQL username
* @param string $password MySQL password
* @return boolean
*/
private function connect($hostname,$username,$password)
{
else return $this->ready = true;
}
/**
* MySQL select database
*
* @param string $database MySQL database name to use
* @return boolean
*/
public function select_db($database = '')
{
$this->ready = false;
}
else $this->database = $database;
return true;
}
/**
* MySQL query
*
* @param string $sentence MySQL query sentence
* @return integer Number of selected rows
*/
public function query($sentence = '')
{
if (!$this->result) {
$this->query_error = true;
}
if (preg_match('/^\s*(insert|replace)(.+)/is',$sentence))
if (preg_match('/^\s*(select)(.+)/is', $sentence)) { if ($this->affected_rows > 0) {
$rows = 0;
$this->query_result[$rows] = $row;
$rows++;
}
}
}
if ($this->query_error) $this->query_error = false;
$this->rows = $rows;
return true;
}
/**
* Clean cached query result
*
* @access public
* @return void
*/
public function clean()
{
$this->query_error = false;
$this->query_result = array(); $this->affected_rows = null;
}
/**
* Espaces a string
*
* @access public
* @param string $string
* @return string
*/
public function escape($string)
{
}
}
?>