//【警告】:未經許可請勿隨便修改
//------------------------------------------------------------------------------------------
//------------------------------------------------------------------- " /> 成年人免费在线看,亚洲综合一区二区三区四区,美女视频网站黄色

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

操作Oracle的php類

<?
//【警告】:未經許可請勿隨便修改
//------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------
//   
// 【文件名】:                c_ora_db.inc
// 【作  用】:                Oracle公用函數類
// 【作  者】:                天灰
//  
// 【最后修改日期】:        2001/05/11[cxx]      
// 【變量定義規則】:‘C_'=字符型,‘I_'=整型,‘N_'=數字型,‘L_'=布爾型,‘A_'=數組型
//------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------
//    ※db_logon()                    開啟數據庫連接     
//    ※db_query()                    通用select             
//    ※db_change()                    數據庫改變的通用函數(insert,delete,update)
//    ※db_insert()                    insert,直接調用db_change()
//    ※db_delete()                    delete,直接調用db_change()
//    ※db_update()                    update,直接調用db_change()                 
//    ※db_commit()                    事務遞交
//    ※db_rollback()                    事務回退
//    ※db_logoff()                    斷開數據庫連接
//------------------------------------------------------------------------------------------


Class c_ora_db
{

     
//------------------------------------------------------------------------------------------
//        變量定義
//------------------------------------------------------------------------------------------
    var $C_user          = "";              //數據庫用戶名
    var $C_passwd        = "";            //數據庫口令
    var $C_db            = "";                    //數據庫名
    var $I_linkID        = 0;                          //連線句柄
    var $I_stmtID        = 0;                          //查詢句柄
    var $color             ="";                    //全局顏色
//------------------------------------------------------------------------------------------



//------------------------------------------------------------------------------------------
//        函數名:db_logon()
//        作  用:開啟數據庫連接
//        參  數:無
//        返回值:連線句柄(整型)
//        備  注:無
//------------------------------------------------------------------------------------------
    function  db_logon()    
    {    
        $this->I_linkID =  @OCILogon($this->C_user,$this->C_passwd,$this->C_db);
        if ($this->I_linkID == 0){AlertExit('數據庫鏈接失敗,請與DBA聯系!');}
        return  $this->I_linkID;    
    }
//------------------------------------------------------------------------------------------

       
//------------------------------------------------------------------------------------------
//        函數名:db_query($C_sql,$A_define="",$I_start=-1,$I_end=-1)
//        作  用:select
//        參  數:$C_sql                    sql語句
//                $A_define                需綁定的字段。數組型         
//                $I_start                開始取記錄 -1則取出查詢的所有記錄
//                $I_end                    結束取紀錄
//        返回值:二維數組($A_rs)
//        備  注:通過數字0,1,2....可訪問對應字段的值; 或通過查詢字段名也可訪問對應字段的值
//                如通過$A_rs[0][0]或$A_rs[0]['NAME']或$A_rs[0]['name']都可訪問首條記錄NAME字段
//                $I_start,$I_end是配合分頁使用的參數。
//------------------------------------------------------------------------------------------
    function  db_query($C_sql,$A_define="",$I_start=-1,$I_end=-1)
    {    
       if (!$C_sql){AlertExit("參數不全!");}//檢查參數

       //連接檢測
       if ($this->I_linkID == 0){AlertExit('數據庫鏈接失敗,請與DBA聯系!');}

       //格式檢測
       $this -> I_stmtID = OCIParse($this -> I_linkID,$C_sql);     
       if (!$this -> I_stmtID){AlertExit(' sql格式出錯!請與程序員聯系');}

       //如果沒指定綁定的字段,則從SQL語句中去取
       if($A_define=="")
       {
            $A_Cur = explode("select",$C_sql);
            $A_Cur = explode("from",$A_Cur[1]);
            $A_define = explode(",",$A_Cur[0]);
       }

           //綁定數據庫表字段
        if(gettype($A_define) == "array")            //查詢列是數組
        {
            for($i=0;$i<count($A_define);$i++)
            {
                $A_define_up[$i] = trim(strtoupper($A_define[$i]));    //大寫并去除空格
            }
            for($i=0;$i<count($A_define_up);$i++)
            {
                OCIDefineByName($this -> I_stmtID,"$A_define_up[$i]",&$$A_define[$i]);    //綁定
            }
        }
        elseif(trim($A_define) <> "")                //查詢列只有一個
        {
            $A_define_up = trim(strtoupper($A_define));
            OCIDefineByName($this -> I_stmtID,"$A_define_up",&$$A_define);
        }

        //執行綁定好的SQL語句
        if(!OCIExecute($this -> I_stmtID))
        {
            echo "<font color=red><b>執行出錯:</b></font>SQL Error:<font color=red>$C_sql</font><br>";
            return false;
        }

        $lower = 0;                    //返回二維數組的第一維下標控制變量
        $cnt = 0;                    //開始取數標識

        //取記錄
        while (OCIFetchInto($this -> I_stmtID,&$cur,OCI_ASSOC))
        {
            //取查詢出來的所有記錄
            if ($I_start == -1)
            {
                if (gettype($A_define) == "array")        //查詢列是數組
                {
                    for ($i=0;$i<count($A_define);$i++)
                    {
                        if ($cur[$A_define_up[$i]] <> $$A_define[$i])
                        {
                            $$A_define[$i] = $cur[$A_define_up[$i]];     
                        }
                        $A_rs[$lower][$i] = $$A_define[$i];                    //用數字訪問
                        $A_rs[$lower][$A_define[$i]] = $$A_define[$i];        //用小些訪問
                        $A_rs[$lower][$A_define_up[$i]] = $$A_define[$i];    //用大寫訪問
                    }         
                }
                elseif (trim($A_define) <> "")            //查詢列只有一個
                {

                    if ($cur[$A_define_up] <> $$A_define)
                    {
                        $$A_define = $cur[$A_define_up];     
                    }
                    $A_rs[$lower][0] = $$A_define;                    //用數字訪問
                    $A_rs[$lower][$A_define] = $$A_define;        //用小寫訪問
                    $A_rs[$lower][$A_define_up] = $$A_define;    //用大些訪問
                }
                $lower++;            //下標加一
            }

            //取出指定記錄(配合分頁使用)
            if ($I_start <> -1)
            {
                if ($cnt >= $I_start)
                {
                    $cnt++;
                    if ($I_end - $I_start <> 0)
                    {
                        $I_end--;
                            if (gettype($A_define) == "array")
                            {
                                for($i=0;$i<count($A_define_up);$i++)
                                {
                                    if ($cur[$A_define_up[$i]] <> $$A_define[$i])
                                    {
                                        $$A_define[$i] = $cur[$A_define_up[$i]];     
                                    }
                                    $A_rs[$lower][$i] = $$A_define[$i];                    //用數字訪問
                                    $A_rs[$lower][$A_define[$i]] = $$A_define[$i];        //用小些訪問
                                    $A_rs[$lower][$A_define_up[$i]] = $$A_define[$i];    //用大寫訪問
                                }
                            }elseif(trim($A_define) <> "")
                            {
                                if ($cur[$A_define_up] <> $$A_define)
                                {
                                    $$A_define = $cur[$A_define_up];     
                                }
                                $A_rs[$lower][0] = $$A_define;                    //用數字訪問
                                $A_rs[$lower][$A_define] = $$A_define;        //用小些訪問
                                $A_rs[$lower][$A_define_up] = $$A_define;    //用大寫訪問                     
                            }
                        $lower++;
                    }else
                    {
                        break;        //如果$I_end-$I_start=0  表示取完記錄并跳出while循環
                    }     
                }else
                {
                    $cnt++;        //如果$cnt<$I_start,$cnt++
                }                 
            }

        }     //while的結束

        //釋放句柄并返回查詢數據(一個二維數組)
        OCIFreestatement($this -> I_stmtID);
        return $A_rs;      

    } //function的結束
//------------------------------------------------------------------------------------------


//------------------------------------------------------------------------------------------
//        函數名:db_change($C_sql,$A_bind)
//        作  用:db change
//        參  數:$C_sql                        sql語句
//                $A_bind                        需綁定的字段。數組型         
//        返回值:布爾值
//        備  注:insert,delete,update通用
//------------------------------------------------------------------------------------------
    function db_change($C_sql,$A_bind="")
    {
        if (!$C_sql){AlertExit("參數不全!");}//檢查參數

        //連接檢測
        if($this -> I_linkID==""){    AlertExit("我們的數據庫正忙,請稍后再連接!");}     

        //格式檢測
        $this -> I_stmtID = OCIParse($this -> I_linkID,$C_sql);     
        if (!$this -> I_stmtID){AlertExit(' sql格式出錯!請與程序員聯系');}

        //綁定
        if(gettype($A_bind) == "array")
        {
            for($i=0;$i<count($A_bind);$i++)
            {
                global $$A_bind[$i];
                $$A_bind[$i] = StripSlashes($$A_bind[$i]);            //去掉反斜線字元
                $$A_bind[$i] = str_replace("<?","< ?",$$A_bind[$i]);    //過濾掉php標示
            }
            for($i=0;$i<count($A_bind);$i++){
                OCIBindByName($this -> I_stmtID, ":$A_bind[$i]", &$$A_bind[$i], -1);  //綁定
            }
        }
        elseif(trim($A_bind) <> "")                                //不是數組,是字符
        {
            global $$A_bind;
            $$A_bind = StripSlashes($$A_bind);
            $$A_bind = str_replace("<?","< ?",$$A_bind);                //過濾掉php標示
            OCIBindByName($this -> I_stmtID, ":$arrBind", &$$A_bind, -1);                 
        }

        //執行并檢測是否成功
        if(!OCIExecute($this -> I_stmtID,OCI_DEFAULT))
        {
            echo "<font color=red><b>執行出錯:</b></font>SQL Error:<font color=red>$C_sql</font><br>";
            return false;
        }

        /*//傳回受影響的行數
        global $I_changenum;
        $I_changenum = OCINumrows($this -> I_stmtID);*/

        //釋放句柄,傳回值
        OCIFreeStatement($this -> I_stmtID);
        return true;
    }
//------------------------------------------------------------------------------------------


//------------------------------------------------------------------------------------------
//        函數名:db_delete($C_sql)
//        作  用:delete
//        參  數:C_sql                    sql語句
//        返回值:布爾值
//        備  注:該函數只是為了使用直觀,本質調用db_change()
//------------------------------------------------------------------------------------------
    function db_delete($C_sql)
    {
        return $this -> db_change($C_sql);
    }
//------------------------------------------------------------------------------------------


//------------------------------------------------------------------------------------------
//        函數名:db_insert($C_sql,A_bind)
//        作  用:insert
//        參  數:C_sql                    sql語句
//                A_bind                    綁定
//        返回值:布爾值
//        備  注:該函數只是為了使用直觀,本質調用db_change()
//------------------------------------------------------------------------------------------
    function db_insert($C_sql,$A_bind="")
    {
        return $this -> db_change($C_sql,$A_bind);
    }
//------------------------------------------------------------------------------------------


//------------------------------------------------------------------------------------------
//        函數名:db_update($C_sql,A_bind)
//        作  用:update
//        參  數:C_sql                    sql語句
//                A_bind                    綁定
//        返回值:布爾值
//        備  注:該函數只是為了使用直觀,本質調用db_change()
//------------------------------------------------------------------------------------------
    function db_update($C_sql,$A_bind="")
    {
        return $this -> db_change($C_sql,$A_bind);
    }
//------------------------------------------------------------------------------------------



//------------------------------------------------------------------------------------------
//        函數名:db_commit()
//        作  用:事務遞交
//        參  數:無
//        返回值:布爾值
//        備  注:無
//------------------------------------------------------------------------------------------     
    function db_commit()
    {
        return    (OCICommit($this->I_linkID));
    }     
//------------------------------------------------------------------------------------------


//------------------------------------------------------------------------------------------
//        函數名:db_rollback()
//        作  用:事務回退
//        參  數:無
//        返回值:布爾值
//        備  注:無
//------------------------------------------------------------------------------------------     
    function db_rollback()
    {
        return  (OCIRollback($this->I_linkID));
    }     
//------------------------------------------------------------------------------------------

     
//------------------------------------------------------------------------------------------
//        函數名:db_logoff()
//        作  用:斷開數據庫連接
//        參  數:無
//        返回值:布爾值
//        備  注:無
//------------------------------------------------------------------------------------------     
    function db_logoff()
    {
        return (OCILogoff($this->I_linkID));
    }
//------------------------------------------------------------------------------------------

     
//------------------------------------------------------------------------------------------
}
?> 

php技術操作Oracle的php類,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 一区二区精品视频 | 免费看黄色的视频 | 成人国产午夜在线视频 | 亚洲天堂黄色 | 91插插插插插 | 在线精品国产一区二区 | 伊人色婷婷 | 日韩一区二区三区视频在线观看 | 国产高清视频一区二区 | 永久免费精品影视网站 | 国产在线精品一区二区不卡 | 青草悠悠视频在线观看 | 黄色网址免费在线 | 华人亚洲欧美精品国产 | 女人国产香蕉久久精品 | 国产a久久精品一区二区三区 | 91久久国产情侣真实对白 | 一色屋色费精品视频在线看 | 午夜噜噜 | 国产欧美日韩免费一区二区 | 在线看福利片 | 精品视频一区二区三区在线观看 | 中文字幕视频网 | 亚洲成a人| 欧美系列第一页 | 婷婷sese| 国产一区在线观看免费 | 国产短视频精品区第一页 | 深夜福利小视频 | 青青国产成人久久91网站站 | 国内精品久久久久久麻豆 | 国产精品2019 | 高清免费久久影院 | 久久婷婷伊人 | 久久精品国产亚洲婷婷 | 久久国产精品高清一区二区三区 | 色老板在线视频观看 | 狠狠色综合久久婷婷 | 久久一精品 | 青草视频.com | 91av国产在线 |