• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI and SQL SERVER 2005 and MS ADODB not ADOdb

#1
[eluser]riza_nurhadi[/eluser]
hi im a new to CI and been using it with sql server 2005 with changed ntwdblib.dll.
im using autoload too.

it works fine but it comes with unstable database connection. sometimes its just connect to database server and sometimes its says 'unable to connect to database'. ill just refresh my browser a few times and it connect again.

maybe there is something wrong with the web server and database server. but im not the one who set the server. and i dont care bout it.

im using driver mssql. and with changed ntwdblib.dll.

and now im using ADODB object from MS. to use it ive created some library for it.

this is the library.

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

    class ADODB {
           //////
        var $ado_data_source = '192.168.1.1';
        var $ado_db_name = 'thisisdb';
        var $ado_db_uid = 'sa';
        var $ado_db_pwd = 'iforgot';

       function adodb_query_result_array($sql){
         $conn = new COM("ADODB.Connection") or die("Cannot start ADO");
         $conn->Open("Provider=SQLOLEDB; Data Source=".$this->ado_data_source.";
         Initial Catalog=".$this->ado_db_name."; User ID=".$this->ado_db_uid."; Password=".$this->ado_db_pwd."");
        
        
         $rs = $conn->Execute($sql);
         $num_columns = $rs->Fields->Count();
         $ado_field_name = array();
         for ($i=0; $i < $num_columns; $i++) {
          $ado_field_name[] = $rs->Fields($i)->Name;
         }
        
         $result = array();
         $test = array();
         $rowcount = 0;
         if(!$rs->EOF && !$rs->BOF) {
         $rs->MoveFirst;
          while (!$rs->EOF) {
          for ($i=0; $i < $num_columns; $i++) {
            $result[$rowcount][$ado_field_name[$i]] = $rs->Fields[$i]->value;
        }
          $rs->MoveNext();
          $rowcount++;
         }
         }
         $rs->Close();
         $conn->Close();
         $conn = null;
          return $result;
       }
      
          function adodb_query_insert_id($sql){
          $conn = new COM("ADODB.Connection") or die("Cannot start ADO");
         $conn->Open("Provider=SQLOLEDB; Data Source=".$this->ado_data_source.";
         Initial Catalog=".$this->ado_db_name."; User ID=".$this->ado_db_uid."; Password=".$this->ado_db_pwd."");
         $conn->Execute($sql);
         $sql = " SELECT @@IDENTITY AS last_id";
         $rs =  $conn->Execute($sql);
         $insertid = $rs->Fields[0]->value;
         return $insertid;
       }
      
       function adodb_query_execute($sql){
         $conn = new COM("ADODB.Connection") or die("Cannot start ADO");
         $conn->Open("Provider=SQLOLEDB; Data Source=".$this->ado_data_source.";
         Initial Catalog=".$this->ado_db_name."; User ID=".$this->ado_db_uid."; Password=".$this->ado_db_pwd."");
         $conn->Execute($sql);
         $conn->Close();
         $conn = null;
       }


    }

?&gt;

the result is the execution time is getting longer...its really slow..

ive tried sqlsvr driver...but it just gone blank...

as you see... im creating this to match the result_array and insert_id function. and creating some stable connection to the database.

if anyone have interest in this i appreciate it..
see ya in few weeks

please forgive for my bad English.


Messages In This Thread
CI and SQL SERVER 2005 and MS ADODB not ADOdb - by El Forum - 04-21-2009, 10:32 AM
CI and SQL SERVER 2005 and MS ADODB not ADOdb - by El Forum - 04-22-2009, 06:18 AM
CI and SQL SERVER 2005 and MS ADODB not ADOdb - by El Forum - 05-06-2009, 03:07 AM
CI and SQL SERVER 2005 and MS ADODB not ADOdb - by El Forum - 05-06-2009, 03:23 AM
CI and SQL SERVER 2005 and MS ADODB not ADOdb - by El Forum - 05-06-2009, 03:31 AM
CI and SQL SERVER 2005 and MS ADODB not ADOdb - by El Forum - 05-06-2009, 03:39 AM
CI and SQL SERVER 2005 and MS ADODB not ADOdb - by El Forum - 05-06-2009, 11:54 AM
CI and SQL SERVER 2005 and MS ADODB not ADOdb - by El Forum - 05-12-2009, 03:33 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.