Игорь_Vasinsky
23.06.2013 - 22:27
nты переведи текст ошибок
_____________
HTML, CSS (Bootstrap), JS(JQuery, ExtJS), PHP, MySQL, MSSql, Posgres, (TSql, BI OLAP, MDX), Mongo, Git, SVN, CodeIgnater, Symfony, Yii 2, JiRA, Redmine, Bitbucket, Composer, Rabbit MQ, Amazon (SQS, S3, Transcribe), Docker
Nikitian
23.06.2013 - 22:27
Хотя бы так
Class MySQL{
@var
protected $link = null;
public function __construct(){
$this->link=mysql_connect(DB_HOST, DB_NAME, DB_PASS);
if($this->link===false || !is_resource($this->link))throw new Exception(mysql_error($this->link));
@mysql_query ("set character_set_client='".CHARACTER."'",$this->link);
@mysql_query ("set character_set_results='".CHARACTER."'",$this->link);
@mysql_query ("set collation_connection='".CHARACTER_FULL."'",$this->link);
$result=mysql_select_db(DB_NAME,$this->link);
if($result===false)throw new Exception(mysql_error($this->link));
mysql_query("SET NAMES '".CHARACTER."'",$this->link);
return $result;
}
static public function query($query,$r= null,$mf =null){
if($this->link===null || !is_resource($this->link))throw new Exception('Not connected');
$result=mysql_query($query,$this->link);
if($result===false)throw new Exception(mysql_error($this->link));
if(!$r or $r=='res'){
return $result;
}elseif($r=='row' && $mf == 'array'){
$row = mysql_fetch_array($result);
return $row;
}elseif($r=='row' && $mf == 'cont'){
$row = mysql_fetch_assoc($result);
return count($row);
}elseif($r=='row' && $mf == 'assoc'){
$row = mysql_fetch_assoc($result);
return $row;
}
}
public function __destruct(){
if($this->link===null || !is_resource($this->link))throw new Exception('Not connected');
mysql_close($this->link);
}
}
Но всё-равно это не далее учебного пособия можно использовать.