Библиотека для cis, online, cms1
This commit is contained in:
commit
3c2e614d87
269 changed files with 39854 additions and 0 deletions
50
core/drivers/database.mysql.php
Normal file
50
core/drivers/database.mysql.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/drivers/db.php';
|
||||
|
||||
/**
|
||||
* Ïðîñòîé êëàññ äëÿ ðàáîòû ñ áàçàìè äàííûõ
|
||||
*/
|
||||
class Database_MYSQL extends DB implements IDatabase
|
||||
{
|
||||
public function connect(array $dsn)
|
||||
{
|
||||
$db = @mysql_pconnect($dsn['hostspec'], $dsn['username'], $dsn['password'])
|
||||
or die("Unable connect to database!");
|
||||
|
||||
mysql_select_db($dsn['database']);
|
||||
return ($this->db = $db);
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
return mysql_close($this->db);
|
||||
}
|
||||
|
||||
public function query($query)
|
||||
{
|
||||
$res = mysql_query($this->db, $query)
|
||||
or die("Error: wrong SQL query #$query#");
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function fetchAllArray($query)
|
||||
{
|
||||
$res = $this->query($query);
|
||||
|
||||
while ($row = mysql_fetch_array ($res))
|
||||
$rows[] = $row;
|
||||
mysql_free_result($res);
|
||||
return ($rows) ? $rows : array();
|
||||
}
|
||||
|
||||
public function fetchOneArray($query)
|
||||
{
|
||||
$res = $this->query($query);
|
||||
$row = mysql_fetch_array($res);
|
||||
mysql_free_result($res);
|
||||
return ($row) ? $row : array();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue