GetOne('select SCOPE_IDENTITY()'); } function _affectedrows() { return $this->GetOne('select @@rowcount'); } function SetTransactionMode( $transaction_mode ) { $this->_transmode = $transaction_mode; if (empty($transaction_mode)) { $this->Execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED'); return; } if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode; $this->Execute("SET TRANSACTION ".$transaction_mode); } function qStr($s, $magic_quotes=false) { $s = ADOConnection::qStr($s); return str_replace("\0", "\\\\000", $s); } function MetaColumns($table, $normalize=true) { $table = strtoupper($table); $arr= array(); $dbc = $this->_connectionID; $osoptions = array(); $osoptions[0] = null; $osoptions[1] = null; $osoptions[2] = $table; $osoptions[3] = null; $adors=@$dbc->OpenSchema(4, $osoptions);//tables if ($adors){ while (!$adors->EOF){ $fld = new ADOFieldObject(); $c = $adors->Fields(3); $fld->name = $c->Value; $fld->type = 'CHAR'; // cannot discover type in ADO! $fld->max_length = -1; $arr[strtoupper($fld->name)]=$fld; $adors->MoveNext(); } $adors->Close(); } $false = false; return empty($arr) ? $false : $arr; } function CreateSequence($seq='adodbseq',$start=1) { $this->Execute('BEGIN TRANSACTION adodbseq'); $start -= 1; $this->Execute("create table $seq (id float(53))"); $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); if (!$ok) { $this->Execute('ROLLBACK TRANSACTION adodbseq'); return false; } $this->Execute('COMMIT TRANSACTION adodbseq'); return true; } function GenID($seq='adodbseq',$start=1) { //$this->debug=1; $this->Execute('BEGIN TRANSACTION adodbseq'); $ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1"); if (!$ok) { $this->Execute("create table $seq (id float(53))"); $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); if (!$ok) { $this->Execute('ROLLBACK TRANSACTION adodbseq'); return false; } $this->Execute('COMMIT TRANSACTION adodbseq'); return $start; } $num = $this->GetOne("select id from $seq"); $this->Execute('COMMIT TRANSACTION adodbseq'); return $num; // in old implementation, pre 1.90, we returned GUID... //return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'"); } } // end class class ADORecordSet_ado_mssql extends ADORecordSet_ado { var $databaseType = 'ado_mssql'; }