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