When we are applying
PHP application ODBC specific code:
- Class odbc_db
- {
- var $ Con = NULL ;
- var $ Resource = NULL ;
- function __construct ()
- {
- }
- function Connect ($dsn = ",
$user = ", $passwd =",
$cursor_type = 0)
- {
- ! $dsn && $this- > Debug (' DSN not provided! ');
- $this- > Con = Odbc_connect ($DSN, $user
, $passwd, $cursor _type);
- ! $this- > con && $this- > Debug (' Conncet failed! ');
- return $this- > con;
- }
- function Query ($sql = ")
- {
- $this- > Resource = odbc_exec ($this->con, $sql);
- ! $this- > resource && $this- > Debug
(' Query failed! ');
- return $this- > resource;
- }
- function Fetch_array ($resource = ")
- {
- ! $resource && $ Resource = $this- > resource;
- Return Odbc_fetch_array ($resource);
- }
- function Query_first ($sql = ")
- {
- $ Resource = $this- > query ($sql);
- Return Odbc_fetch_array ($resource);
- }
- function Fetch_all ($resource = ")
- {
- ! $resource && $ Resource = $this- > resource;
- $ Results = Array ();
- While (False!== ($row = @odbc_fetch_
Array ($resource)))
- {
- $results [] = $row;
- }
- return $results;
- }
- function Num_rows ()
- {
- return Odbc_num_rows ($this->con);
- }
- function Affected_rows ()
- {
- return Odbc_num_rows ($this->con);
- }
- function Debug ($message = ")
- {
- $message . = '
- The following error message is provided by ODBC: '. Odbc_errormsg ();
- Exit ($message);
- }
- function __destruct ()
- {
- odbc_close ($this->con);
- }
- }
- ?>
The above is the PHP application of all the methods of ODBC, we hope to help.
http://www.bkjia.com/PHPjc/446028.html www.bkjia.com true http://www.bkjia.com/PHPjc/446028.html techarticle when we apply the ODBC specific code in PHP application: classodbc_db {var$ con = null; var$ resource = null; Function__construct () {} Functionconne CT ($ DSN =, $ user =,$ passwd =, $ cu ...