{% else-1 %}
Класс для работы с БД через новую библиотеку MySqlI

                        
<?php  

$date = '10.5.2008';
* $db = new DB('localhost','root','','mydb');
* $db->mysql_qw('UPDATE `news` SET `date`=?',$date);


class DB
{
public function __construct($host,$user,$db_pass,$db)
{
$this->connect = mysqli_connect($host,$user,$db_pass);
mysqli_select_db($this->connect,$db);
}
function mysql_qw()
{
$this->args = func_get_args();
$qwery = $this->mysql_make_qw();
return $result = mysqli_query($this->connect,$qwery);
mysqli_free_result($result);
}

private function mysql_make_qw()
{
$tml = $this->args;
$tml[0] = str_replace('%','%%',$tml[0]);
$tml[0] = str_replace('?','%s',$tml[0]);
foreach ($tml as $i => $v)
{
if (!$i)
{
continue;
}
if (is_int($v))
{
continue;
}
$tml[$i] = "'" . mysqli_escape_string($this->connect,$v) . "'";
}
for ($i = $c = count($tml) - 1; $i < $c + 20; $i++)
{
$tml[$i + 1] = "UNKNOWN_PLACEHOLDER_$i";
return call_user_func_array("sprintf",$tml);
}
}

public function __destruct()
{
mysqli_close($this->connect);
}
}
?>
0 129 0
0

Нет фото
Sheldon * 3.25
• 9 мар 2013, 10:44


MySQLi

0

Нет фото
3KZO * 4.92
• 5 фев 2013, 21:23


pdo?