|
[PHP]<?php
/**
* describe
*
* detail info
*
* @example example here
* @author Justin NBX <justin@luckygroup.net>
* @version $Id$
*/
class AdodbLite
{
var $conn;
var $db;
var $db_type;
var $db_host;
var $db_user;
var $db_password;
var $db_user;
var $db_name;
var $sql_query;
var $result;
function AdodbLite($db_type)
{
return true;
}
function PConnect($db_host, $db_user, $db_password, $db_name)
{
$this->conn = mysql_pconnect($db_host, $db_user, $db_password);
mysql_select_db($db_name, $this->conn);
}
function Connect($db_host, $db_user, $db_password, $db_name)
{
$this->conn = mysql_connect($db_host, $db_user, $db_password);
mysql_select_db($db_name, $this->conn);
}
function Execute($sql)
{
if(!$result = mysql_query($sql, $this->conn))return false;
$this->result = new AdoResult($result, $this->conn);
return $this->result;
}
function _Execute($sql)
{
return $this->Execute($sql);
}
function Insert_ID($id=0)
{
$insert_id = ($id)?$id:mysql_insert_id($this->conn);
}
function GetAssoc($sql)
{
if(!$result = mysql_query($sql, $this->conn))return false;
while($row = mysql_fetch_assoc($result))
{
$keys = array_keys($row);
$key = $row[$keys[0]];
unset($row[$keys[0]]);
$rows[$key] = $row;
if(count($row)<=2)$rows[$key] = $row[$keys[1]];
}
return $rows;
}
function Close()
{
return mysql_close($this->conn);
}
function ErrorMsg()
{
return mysql_error();
}
}
class AdoResult
{
var $result;
var $rows;
var $conn;
function AdoResult($result, $conn)
{
$this->result = $result;
$this->conn = $conn;
}
function RecordCount()
{
return mysql_num_rows($this->result);
}
function fetchRow()
{
return @mysql_fetch_assoc($this->result);
}
function getRows()
{
while($row = mysql_fetch_assoc($this->result))
{
$rows[] = $row;
}
return $rows;
}
function fetchObject()
{
return @mysql_fetch_object($this->result);
}
function GetAssoc()
{
while($row = mysql_fetch_assoc($this->result))
{
$keys = array_keys($row);
$key = $row[$keys[0]];
unset($row[$keys[0]]);
$rows[$key] = $row;
if(count($row)<=2)$rows[$key] = $row[$keys[1]];
}
return $rows;
}
function Close()
{
return mysql_free_result($this->result);
}
function fields($name)
{
$row = mysql_fetch_assoc($this->result);
return $row[$name];
}
}
?>[/PHP] |
|