Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to apply odbc skills in PHP

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

PHP how to apply odbc skills, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

When we use PHP language to operate on ACCESS database, we usually use odbc in PHP. Let's take a look at how the PHP application odbc operates the ACCESS database.

The specific code of PHP application odbc:

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 funds')

$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)

}

}

? >

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report