<del id="d4fwx"><form id="d4fwx"></form></del>
      <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

            <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
          • php訪問數(shù)據(jù)庫實(shí)例,PHP調(diào)用數(shù)據(jù)庫

            PHP調(diào)用三種數(shù)據(jù)庫的方法(3)

            Oracle(甲骨文)是世界上最為流行的關(guān)系數(shù)據(jù)庫。它是大公司推崇的工業(yè)化的強(qiáng)有力的引擎。我們先看看其相關(guān)的函數(shù):

            10年積累的成都做網(wǎng)站、網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先制作網(wǎng)站后付款的網(wǎng)站建設(shè)流程,更有定日免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

            (1)integer

            ora_logon(string

            user

            ,

            string

            password)

            開始對(duì)一個(gè)Oracle數(shù)據(jù)庫服務(wù)器的連接。

            (2)integer

            ora_open(integer

            connection)

            打開給出的連接的游標(biāo)。

            (3)integer

            ora_do(integer

            connection,

            string

            query)

            在給出的連接上執(zhí)行查詢。PHP生成一個(gè)指示器,解析查詢,并執(zhí)行之。

            (4)integer

            ora_parse(integer

            cursor,

            string

            query)

            解析一個(gè)查詢并準(zhǔn)備好執(zhí)行。

            (5)boolean

            ora_exec(integer

            cursor)

            執(zhí)行一個(gè)先前由ora_parse函數(shù)解析過的查詢。

            (6)boolean

            ora_fetch(integer

            cursor)

            此函數(shù)會(huì)使得一個(gè)執(zhí)行過的查詢中的行被取到指示器中。這使得您可以調(diào)用ora_getcolumn函數(shù)。

            (7)string

            ora_getcolumn(integer

            cursor,

            integer

            column)

            返回當(dāng)前的值。列由零開始的數(shù)字索引。

            (8)boolean

            ora_logoff(integer

            connection)

            斷開對(duì)數(shù)據(jù)庫服務(wù)器的鏈接。

            以下是向ORACLE數(shù)據(jù)庫插入數(shù)據(jù)的示例程序:

            html

            headtitle向ORACLE數(shù)據(jù)庫中插入數(shù)據(jù)/title/head

            body

            form

            action="?echo

            $PHP_SELF;?"

            method="post"

            table

            border="1"

            cellspacing="0"

            cellpadding="0"

            tr

            thID/th

            thname/th

            thDescription/th

            /tr

            tr

            tdinput

            type="text"

            name="name"

            maxlength="50"

            size="10"/td

            tdinput

            type="text"

            name="email"

            maxlength="255"

            size="30"/td

            tdinput

            type="text"

            name="Description"

            maxlength="255"

            size="50"/td

            /tr

            tr

            align="center"

            td

            colspan="3"input

            type="submit"

            value="提交" input

            type="reset"

            value="重寫"/td

            /tr

            /table

            /form

            ?

            //先設(shè)置兩個(gè)環(huán)境變量ORACLE_HOME,ORACLE_SID

            putenv("ORACLE_HOME=/oracle/app/oracle/product/8.0.4");

            putenv("ORACLE_SID=ora8");

            //設(shè)置網(wǎng)頁顯示中文

            putenv("NLS_LANG=Simplified_Chinese.zhs16cgb231280");

            if($connection=ora_logon("scott","tiger"))

            {

            //庫表test有ID,name,Description三項(xiàng)

            $sql

            =

            'insert

            into

            test(ID,name,Description)

            values

            ';

            $sql

            .=

            '(''

            .

            $ID

            .

            '',''

            .

            $name

            .

            '',''.

            $Description

            .

            '')';

            if($cursor=ora_do($connect,$sql))

            {

            print("insert

            finished!");

            }

            $query

            =

            'select

            *

            from

            test';

            if($cursor=ora_do($connect,$query))

            {

            ora_fetch($cursor);

            $content0=ora_getcolumn($cursor,0);

            $content1=ora_getcolumn($cursor,1);

            $content2=ora_getcolumn($cursor,2);

            print("$content0");

            print("$content1");

            print("$content2");

            ora_close($cursor);

            }

            ora_logoff($connection);

            }

            ?

            /body

            /html

            PHP利用pdo_odbc實(shí)現(xiàn)連接數(shù)據(jù)庫示例【基于ThinkPHP5.1搭建的項(xiàng)目】

            本文實(shí)例講述了PHP利用pdo_odbc實(shí)現(xiàn)連接數(shù)據(jù)庫。分享給大家供大家參考,具體如下:

            目的:從sql

            server數(shù)據(jù)庫里面把某個(gè)視圖文件調(diào)用出來,以鍵值對(duì)的方式顯示在頁面上。

            利用pdo

            odbc來實(shí)現(xiàn)PHP連接數(shù)據(jù)庫:

            在PHP配置文件里面開啟pdo_odbc.dll服務(wù)。重啟Apache服務(wù)器。

            在ThinkPHP5.1的項(xiàng)目中在模塊里添加config添加規(guī)定好的樣式數(shù)據(jù)庫:

            代碼如下:

            ?php

            return

            [

            //

            數(shù)據(jù)庫類型

            'type'

            =

            'sqlsrv',

            //

            服務(wù)器地址

            'hostname'

            =

            'localhost',

            //

            數(shù)據(jù)庫名

            'database'

            =

            'mysql',

            //

            用戶名

            'username'

            =

            'sa',

            //

            密碼

            'password'

            =

            '123456',

            //

            端口

            'hostport'

            =

            '',

            //

            連接dsn

            'dsn'

            =

            'odbc:Driver={SQL

            Server};Server=localhost;Database=mysql',

            //

            數(shù)據(jù)庫連接參數(shù)

            'params'

            =

            [],

            //

            數(shù)據(jù)庫編碼默認(rèn)采用utf8

            'charset'

            =

            'utf8',

            //

            數(shù)據(jù)庫表前綴

            'prefix'

            =

            '',

            //

            數(shù)據(jù)庫調(diào)試模式

            'debug'

            =

            true,

            //

            數(shù)據(jù)庫部署方式:0

            集中式(單一服務(wù)器),1

            分布式(主從服務(wù)器)

            'deploy'

            =

            0,

            //

            數(shù)據(jù)庫讀寫是否分離

            主從式有效

            'rw_separate'

            =

            false,

            //

            讀寫分離后

            主服務(wù)器數(shù)量

            'master_num'

            =

            1,

            //

            指定從服務(wù)器序號(hào)

            'slave_no'

            =

            '',

            //

            是否嚴(yán)格檢查字段是否存在

            'fields_strict'

            =

            true,

            //

            數(shù)據(jù)集返回類型

            'resultset_type'

            =

            'array',

            //

            自動(dòng)寫入時(shí)間戳字段

            'auto_timestamp'

            =

            false,

            //

            時(shí)間字段取出后的默認(rèn)時(shí)間格式

            'datetime_format'

            =

            'Y-m-d

            H:i:s',

            //

            是否需要進(jìn)行SQL性能分析

            'sql_explain'

            =

            false,

            //

            Builder類

            'builder'

            =

            '',

            //

            Query類

            'query'

            =

            '\\think\\db\\Query',

            //

            是否需要斷線重連

            'break_reconnect'

            =

            false,

            //

            斷線標(biāo)識(shí)字符串

            'break_match_str'

            =

            [],

            ];

            ?

            在控制器controller里面建一個(gè)控制文件Test.php

            代碼如下:

            ?php

            namespace

            app\index\controller;

            use

            think\Db;

            use

            think\Controller;

            class

            Test

            extends

            Controller

            {

            public

            function

            zz(){

            $data=Db::view('View_2')-select();

            echo

            json_encode($data);

            }

            }

            ?

            最后調(diào)用入口文件即可訪問。

            我的效果:

            [{"111":"123","1112":"LLP","232":"1","ROW_NUMBER":"1"},{"111":"123","1112":"BB","232":"2","ROW_NUMBER":"2"}]

            更多關(guān)于thinkPHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《ThinkPHP入門教程》、《thinkPHP模板操作技巧總結(jié)》、《ThinkPHP常用方法總結(jié)》、《codeigniter入門教程》、《CI(CodeIgniter)框架進(jìn)階教程》、《Zend

            FrameWork框架入門教程》及《PHP模板技術(shù)總結(jié)》。

            希望本文所述對(duì)大家基于ThinkPHP框架的PHP程序設(shè)計(jì)有所幫助。

            您可能感興趣的文章:ThinkPHP實(shí)現(xiàn)多數(shù)據(jù)庫連接的解決方法tp5(thinkPHP5)框架實(shí)現(xiàn)多數(shù)據(jù)庫查詢的方法ThinkPHP3.1新特性之多數(shù)據(jù)庫操作更加完善tp5(thinkPHP5)框架連接數(shù)據(jù)庫的方法示例PHP7使用ODBC連接SQL

            Server2008

            R2數(shù)據(jù)庫示例【基于thinkPHP5.1框架】thinkPHP5實(shí)現(xiàn)的查詢數(shù)據(jù)庫并返回json數(shù)據(jù)實(shí)例tp5(thinkPHP5)操作mongoDB數(shù)據(jù)庫的方法tp5(thinkPHP5)框架數(shù)據(jù)庫Db增刪改查常見操作總結(jié)thinkPHP5框架實(shí)現(xiàn)多數(shù)據(jù)庫連接,跨數(shù)據(jù)連接查詢操作示例

            php連接遠(yuǎn)程數(shù)據(jù)庫

            在php中如果要連接遠(yuǎn)程數(shù)據(jù)庫連接方法很簡單,只要把本地連接localhost或127.0.0.1改成指定遠(yuǎn)程服務(wù)器一IP地址或者直接域名即可。

            語法

            mysql_connect(servername,username,password);

            例子

            在下面的例子中,我們?cè)谝粋€(gè)變量中?($con)?存放了在腳本中供稍后使用的連接。如果連接失敗,將執(zhí)行?"die"?部分:

            代碼如下:

            ?php

            $con?=?mysql_connect("localhost","peter","abc123");

            if?(!$con)

            {

            die('Could?not?connect:?'?.?mysql_error());

            }

            //?some?code

            ?

            上面是連接本地?cái)?shù)據(jù)庫,下面把localhost改成遠(yuǎn)程IP即可了

            實(shí)例 代碼如下:

            $conn=mysql_connect('','root','123456888');

            if(!$conn)?echo?"失敗!";

            else?echo?"成功!";

            //?從表中提取信息的sql語句

            $sql="SELECT?*?FROM?user?where?userName='$user_name'";

            //?執(zhí)行sql查詢

            $result=mysql_db_query('info',?$sql,?$conn);

            //?獲取查詢結(jié)果

            $row=mysql_fetch_row($result);

            mysql_close();

            幾種常用PHP連接數(shù)據(jù)庫的代碼示例

            sybase_connect連上數(shù)據(jù)庫。

            語法: int sybase_connect(string [servername], string [username], string [password]);

            返回值: 整數(shù)函數(shù)種類: 數(shù)據(jù)庫功能 本函數(shù)用來打開與 Sybase 數(shù)據(jù)庫的連接。

            參數(shù) servername 為欲連上的數(shù)據(jù)庫服務(wù)器名稱。

            參數(shù) username 及 password 可省略,分別為連接使用的帳號(hào)及密碼。

            使用本函數(shù)需注意早點(diǎn)關(guān)閉數(shù)據(jù)庫,以減少系統(tǒng)的負(fù)擔(dān)。

            連接成功則返回?cái)?shù)據(jù)庫的連接代號(hào),失敗返回 false 值。

            php使用pdo連接mssql server數(shù)據(jù)庫實(shí)例

            本文實(shí)例講述了利用php的pdo來連接微軟的mssql

            server數(shù)據(jù)庫的方法,分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

            復(fù)制代碼

            代碼如下:$dsn

            =

            'mssql:dbname=bookStore_demo;host=192.168.1.106';

            $user

            =

            'sa';

            $password

            =

            '123';

            //mssql_connect('192.168.1.106','sa','123');

            //echo

            22;

            try

            {

            //

            echo

            11;

            $dbh

            =

            new

            PDO($dsn,

            $user,

            $password);

            }

            catch

            (PDOException

            $e)

            {

            echo

            'Connection

            failed:

            '

            .

            $e-getMessage();

            }

            //$sql

            =

            'select

            *

            from

            article';

            $sth

            =

            $dbh-query($sql);

            $result

            =

            $sth-fetchAll();

            var_dump($result);

            希望本文所述對(duì)大家的PHP程序設(shè)計(jì)有所幫助。

            PHP連接操作access數(shù)據(jù)庫實(shí)例

            這篇文章主要介紹了PHP連接操作access數(shù)據(jù)庫實(shí)例,本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下

            因?yàn)橹白龅腜ingSwitch要做一個(gè)WEB展示的前端,因?yàn)橐婚_始用了Delphi和access的結(jié)構(gòu),而Delphi與MySQL的連接又相對(duì)麻煩,最后只能選擇用PHP+Access的組合,比較奇怪,但是也合理·····

            在PHP中連接access數(shù)據(jù)庫的話我們必須ADO來連接,這跟ASP中連接數(shù)據(jù)庫非常的類似。下邊給出了一段DEMO供大家參考。

            ?PHP

            /*

            創(chuàng)建ADO連接

            */

            $conn

            =

            @new

            COM("ADODB.Connection")

            or

            die

            ("ADO

            Connection

            faild.");

            $connstr

            =

            "DRIVER={Microsoft

            Access

            Driver

            (*.mdb)};

            DBQ="

            .

            realpath("DATUM/cnbt.mdb");

            $conn-Open($connstr);

            /*

            創(chuàng)建記錄集查詢

            */

            $rs

            =

            @new

            COM("ADODB.RecordSet");

            $rs-Open("select

            *

            from

            dbo_dirs",$conn,1,3);

            /*

            循環(huán)讀取數(shù)據(jù)

            */

            while(!$rs-eof){

            echo

            "$rs-Fields["title"]-Value;

            echo

            "br/";

            $rs-Movenext();

            //將記錄集指針下移

            }

            $rs-close();

            ?

            這樣運(yùn)行就沒問題了····

            以上所述就是本文的全部內(nèi)容了,希望大家能夠喜歡。

            當(dāng)前題目:php訪問數(shù)據(jù)庫實(shí)例,PHP調(diào)用數(shù)據(jù)庫
            網(wǎng)址分享:http://www.jbt999.com/article6/heejog.html

            成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)手機(jī)網(wǎng)站建設(shè)、Google、網(wǎng)站建設(shè)定制開發(fā)、用戶體驗(yàn)

            廣告

            聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

            成都app開發(fā)公司

              <del id="d4fwx"><form id="d4fwx"></form></del>
              <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

                    <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
                  • 港台靓女性啪啪天美传媒精品性88xo | 中文字幕在线播放亚洲 | 色五月天婷婷丁香 | 麻豆操逼片| 91精品国产综合久久久不卡电影 |