Файл: system/system/classes/dizkod/DB.php
Строк: 66
<?defined('SYSPATH') or die('<b>403<br />Запрет доступа</b>');
class dizkod_DB{
private static $instance;
function __construct(){
$connect=@mysql_connect(HOST,USER,PASS) or die (parent::err("Невозможно подключиться к серверу MySQL!"));
@mysql_select_db(BASE,$connect) or die (parent::err("База данных :".BASE." не найдена!"));
@mysql_query("SET NAMES 'utf8'", $connect);
}
public static function Instance()
{
if (self::$instance == null)
self::$instance = new DB();
return self::$instance;
}
public function select($table,$where,$field='*')
{
if(!empty($where)){
$where = " WHERE ".$where;
}
$res=mysql_query("SELECT $field FROM $table $where ") or die (mysql_Error());
return $res;
}
public function update($table,$field,$where)
{
if(!empty($where))
{
$where = " WHERE ".$where;
}
mysql_query("UPDATE $table SET $field $where ");
return mysql_affected_rows();
}
public function insert($table,$fields,$values)
{
mysql_query("INSERT INTO $table ($fields) VALUES($values)") or mysql_Error();
return mysql_insert_id();
}
public function delete($table,$where)
{
if(!empty($where))
{
$where = " WHERE ".$where;
}
mysql_query("DELETE FROM $table $where");
return mysql_affected_rows();
}
public function assoc($table,$where,$field='*')
{
$assoc = $this->select($table,$where,$field='*');
return mysql_fetch_assoc($assoc);
}
public function arr($table,$where,$field='*')
{
$array = $this->select($table,$where,$field='*');
return mysql_fetch_array($array);
}
public function obj($table,$where,$field='*')
{
$obj = $this->select($table,$where,$field='*');
return mysql_fetch_object($obj);
}
public function row($table,$where,$field='*')
{
$row = $this->select($table,$where,$field='*');
return mysql_fetch_row($row);
}
public function num_rows($table,$where,$field='*')
{
$num_rows = $this->select($table,$where,$field='*');
return mysql_num_rows($num_rows);
}
public function result($table,$where,$field='*',$field='0')
{
$result = $this->select($table,$where,$field='*');
return mysql_result($result,$field);
}
}