ona  18.1.1
About: OpenNetAdmin provides a database managed inventory of your IP network (with Web and CLI interface).
  Fossies Dox: ona-18.1.1.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

adodb-mssqlnative.inc.php
Go to the documentation of this file.
1 <?php
2 /*
3 @version v5.20.9 21-Dec-2016
4 @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
5 @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
6  Released under both BSD license and Lesser GPL library license.
7  Whenever there is any discrepancy between the two licenses,
8  the BSD license will take precedence.
9 Set tabs to 4 for best viewing.
10 
11  Latest version is available at http://adodb.sourceforge.net
12 
13  Native mssql driver. Requires mssql client. Works on Windows.
14  http://www.microsoft.com/sql/technologies/php/default.mspx
15  To configure for Unix, see
16  http://phpbuilder.com/columns/alberto20000919.php3
17 
18  $stream = sqlsrv_get_field($stmt, $index, SQLSRV_SQLTYPE_STREAM(SQLSRV_ENC_BINARY));
19  stream_filter_append($stream, "convert.iconv.ucs-2/utf-8"); // Voila, UTF-8 can be read directly from $stream
20 
21 */
22 
23 // security - hide paths
24 if (!defined('ADODB_DIR')) die();
25 
26 if (!function_exists('sqlsrv_configure')) {
27  die("mssqlnative extension not installed");
28 }
29 
30 if (!function_exists('sqlsrv_set_error_handling')) {
31  function sqlsrv_set_error_handling($constant) {
32  sqlsrv_configure("WarningsReturnAsErrors", $constant);
33  }
34 }
35 if (!function_exists('sqlsrv_log_set_severity')) {
36  function sqlsrv_log_set_severity($constant) {
37  sqlsrv_configure("LogSeverity", $constant);
38  }
39 }
40 if (!function_exists('sqlsrv_log_set_subsystems')) {
41  function sqlsrv_log_set_subsystems($constant) {
42  sqlsrv_configure("LogSubsystems", $constant);
43  }
44 }
45 
46 
47 //----------------------------------------------------------------
48 // MSSQL returns dates with the format Oct 13 2002 or 13 Oct 2002
49 // and this causes tons of problems because localized versions of
50 // MSSQL will return the dates in dmy or mdy order; and also the
51 // month strings depends on what language has been configured. The
52 // following two variables allow you to control the localization
53 // settings - Ugh.
54 //
55 // MORE LOCALIZATION INFO
56 // ----------------------
57 // To configure datetime, look for and modify sqlcommn.loc,
58 // typically found in c:\mssql\install
59 // Also read :
60 // http://support.microsoft.com/default.aspx?scid=kb;EN-US;q220918
61 // Alternatively use:
62 // CONVERT(char(12),datecol,120)
63 //
64 // Also if your month is showing as month-1,
65 // e.g. Jan 13, 2002 is showing as 13/0/2002, then see
66 // http://phplens.com/lens/lensforum/msgs.php?id=7048&x=1
67 // it's a localisation problem.
68 //----------------------------------------------------------------
69 
70 
71 // has datetime converstion to YYYY-MM-DD format, and also mssql_fetch_assoc
72 if (ADODB_PHPVER >= 0x4300) {
73 // docs say 4.2.0, but testing shows only since 4.3.0 does it work!
74  ini_set('mssql.datetimeconvert',0);
75 } else {
76  global $ADODB_mssql_mths; // array, months must be upper-case
79  'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,
80  'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12);
81 }
82 
83 class ADODB_mssqlnative extends ADOConnection {
84  var $databaseType = "mssqlnative";
85  var $dataProvider = "mssqlnative";
86  var $replaceQuote = "''"; // string to use to replace quotes
87  var $fmtDate = "'Y-m-d'";
88  var $fmtTimeStamp = "'Y-m-d\TH:i:s'";
89  var $hasInsertID = true;
90  var $substr = "substring";
91  var $length = 'len';
92  var $hasAffectedRows = true;
93  var $poorAffectedRows = false;
94  var $metaDatabasesSQL = "select name from sys.sysdatabases where name <> 'master'";
95  var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))";
97  "select c.name,
98  t.name as type,
99  c.length,
100  c.xprec as precision,
101  c.xscale as scale,
102  c.isnullable as nullable,
103  c.cdefault as default_value,
104  c.xtype,
105  t.length as type_length,
106  sc.is_identity
107  from syscolumns c
108  join systypes t on t.xusertype=c.xusertype
109  join sysobjects o on o.id=c.id
110  join sys.tables st on st.name=o.name
111  join sys.columns sc on sc.object_id = st.object_id and sc.name=c.name
112  where o.name='%s'";
113  var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
114  var $hasGenID = true;
115  var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
116  var $sysTimeStamp = 'GetDate()';
117  var $maxParameterLen = 4000;
118  var $arrayClass = 'ADORecordSet_array_mssqlnative';
119  var $uniqueSort = true;
120  var $leftOuter = '*=';
121  var $rightOuter = '=*';
122  var $ansiOuter = true; // for mssql7 or later
123  var $identitySQL = 'select SCOPE_IDENTITY()'; // 'select SCOPE_IDENTITY'; # for mssql 2000
124  var $uniqueOrderBy = true;
125  var $_bindInputArray = true;
126  var $_dropSeqSQL = "drop table %s";
127  var $connectionInfo = array();
128  var $cachedSchemaFlush = false;
129  var $sequences = false;
130  var $mssql_version = '';
131 
132  function __construct()
133  {
134  if ($this->debug) {
135  ADOConnection::outp("<pre>");
136  sqlsrv_set_error_handling( SQLSRV_ERRORS_LOG_ALL );
137  sqlsrv_log_set_severity( SQLSRV_LOG_SEVERITY_ALL );
138  sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL);
139  sqlsrv_configure('WarningsReturnAsErrors', 0);
140  } else {
141  sqlsrv_set_error_handling(0);
142  sqlsrv_log_set_severity(0);
143  sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL);
144  sqlsrv_configure('WarningsReturnAsErrors', 0);
145  }
146  }
147 
152  function ServerVersion() {
153  $data = $this->ServerInfo();
154  preg_match('/^\d{2}/', $data['version'], $matches);
155  $version = (int)reset($matches);
156 
157  // We only support SQL Server 2005 and up
158  if($version < 9) {
159  die("SQL SERVER VERSION {$data['version']} NOT SUPPORTED IN mssqlnative DRIVER");
160  }
161 
162  $this->mssql_version = $version;
163  }
164 
165  function ServerInfo() {
166  global $ADODB_FETCH_MODE;
167  static $arr = false;
168  if (is_array($arr))
169  return $arr;
170  if ($this->fetchMode === false) {
171  $savem = $ADODB_FETCH_MODE;
172  $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
173  } elseif ($this->fetchMode >=0 && $this->fetchMode <=2) {
174  $savem = $this->fetchMode;
175  } else
176  $savem = $this->SetFetchMode(ADODB_FETCH_NUM);
177 
178  $arrServerInfo = sqlsrv_server_info($this->_connectionID);
179  $ADODB_FETCH_MODE = $savem;
180  $arr['description'] = $arrServerInfo['SQLServerName'].' connected to '.$arrServerInfo['CurrentDatabase'];
181  $arr['version'] = $arrServerInfo['SQLServerVersion'];//ADOConnection::_findvers($arr['description']);
182  return $arr;
183  }
184 
185  function IfNull( $field, $ifNull )
186  {
187  return " ISNULL($field, $ifNull) "; // if MS SQL Server
188  }
189 
190  function _insertid()
191  {
192  // SCOPE_IDENTITY()
193  // Returns the last IDENTITY value inserted into an IDENTITY column in
194  // the same scope. A scope is a module -- a stored procedure, trigger,
195  // function, or batch. Thus, two statements are in the same scope if
196  // they are in the same stored procedure, function, or batch.
197  return $this->lastInsertID;
198  }
199 
200  function _affectedrows()
201  {
202  if ($this->_queryID)
203  return sqlsrv_rows_affected($this->_queryID);
204  }
205 
206  function GenID($seq='adodbseq',$start=1) {
207  if (!$this->mssql_version)
208  $this->ServerVersion();
209  switch($this->mssql_version){
210  case 9:
211  case 10:
212  return $this->GenID2008($seq, $start);
213  break;
214  default:
215  return $this->GenID2012($seq, $start);
216  break;
217  }
218  }
219 
220  function CreateSequence($seq='adodbseq',$start=1)
221  {
222  if (!$this->mssql_version)
223  $this->ServerVersion();
224 
225  switch($this->mssql_version){
226  case 9:
227  case 10:
228  return $this->CreateSequence2008($seq, $start);
229  break;
230  default:
231  return $this->CreateSequence2012($seq, $start);
232  break;
233  }
234 
235  }
236 
240  function CreateSequence2008($seq='adodbseq',$start=1)
241  {
242  if($this->debug) ADOConnection::outp("<hr>CreateSequence($seq,$start)");
243  sqlsrv_begin_transaction($this->_connectionID);
244  $start -= 1;
245  $this->Execute("create table $seq (id int)");//was float(53)
246  $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
247  if (!$ok) {
248  if($this->debug) ADOConnection::outp("<hr>Error: ROLLBACK");
249  sqlsrv_rollback($this->_connectionID);
250  return false;
251  }
252  sqlsrv_commit($this->_connectionID);
253  return true;
254  }
255 
259  function CreateSequence2012($seq='adodbseq',$start=1){
260  if (!$this->sequences){
261  $sql = "SELECT name FROM sys.sequences";
262  $this->sequences = $this->GetCol($sql);
263  }
264  $ok = $this->Execute("CREATE SEQUENCE $seq START WITH $start INCREMENT BY 1");
265  if (!$ok)
266  die("CANNOT CREATE SEQUENCE" . print_r(sqlsrv_errors(),true));
267  $this->sequences[] = $seq;
268  }
269 
273  function GenID2008($seq='adodbseq',$start=1)
274  {
275  if($this->debug) ADOConnection::outp("<hr>CreateSequence($seq,$start)");
276  sqlsrv_begin_transaction($this->_connectionID);
277  $ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1");
278  if (!$ok) {
279  $start -= 1;
280  $this->Execute("create table $seq (id int)");//was float(53)
281  $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
282  if (!$ok) {
283  if($this->debug) ADOConnection::outp("<hr>Error: ROLLBACK");
284  sqlsrv_rollback($this->_connectionID);
285  return false;
286  }
287  }
288  $num = $this->GetOne("select id from $seq");
289  sqlsrv_commit($this->_connectionID);
290  return $num;
291  }
298  function GenID2012($seq='adodbseq',$start=1)
299  {
300 
301  /*
302  * First time in create an array of sequence names that we
303  * can use in later requests to see if the sequence exists
304  * the overhead is creating a list of sequences every time
305  * we need access to at least 1. If we really care about
306  * performance, we could maybe flag a 'nocheck' class variable
307  */
308  if (!$this->sequences){
309  $sql = "SELECT name FROM sys.sequences";
310  $this->sequences = $this->GetCol($sql);
311  }
312  if (!is_array($this->sequences)
313  || is_array($this->sequences) && !in_array($seq,$this->sequences)){
314  $this->CreateSequence2012($seq, $start);
315 
316  }
317  $num = $this->GetOne("SELECT NEXT VALUE FOR $seq");
318  return $num;
319  }
320 
321  // Format date column in sql string given an input format that understands Y M D
322  function SQLDate($fmt, $col=false)
323  {
324  if (!$col) $col = $this->sysTimeStamp;
325  $s = '';
326 
327  $len = strlen($fmt);
328  for ($i=0; $i < $len; $i++) {
329  if ($s) $s .= '+';
330  $ch = $fmt[$i];
331  switch($ch) {
332  case 'Y':
333  case 'y':
334  $s .= "datename(yyyy,$col)";
335  break;
336  case 'M':
337  $s .= "convert(char(3),$col,0)";
338  break;
339  case 'm':
340  $s .= "replace(str(month($col),2),' ','0')";
341  break;
342  case 'Q':
343  case 'q':
344  $s .= "datename(quarter,$col)";
345  break;
346  case 'D':
347  case 'd':
348  $s .= "replace(str(day($col),2),' ','0')";
349  break;
350  case 'h':
351  $s .= "substring(convert(char(14),$col,0),13,2)";
352  break;
353 
354  case 'H':
355  $s .= "replace(str(datepart(hh,$col),2),' ','0')";
356  break;
357 
358  case 'i':
359  $s .= "replace(str(datepart(mi,$col),2),' ','0')";
360  break;
361  case 's':
362  $s .= "replace(str(datepart(ss,$col),2),' ','0')";
363  break;
364  case 'a':
365  case 'A':
366  $s .= "substring(convert(char(19),$col,0),18,2)";
367  break;
368 
369  default:
370  if ($ch == '\\') {
371  $i++;
372  $ch = substr($fmt,$i,1);
373  }
374  $s .= $this->qstr($ch);
375  break;
376  }
377  }
378  return $s;
379  }
380 
381 
382  function BeginTrans()
383  {
384  if ($this->transOff) return true;
385  $this->transCnt += 1;
386  if ($this->debug) ADOConnection::outp('<hr>begin transaction');
387  sqlsrv_begin_transaction($this->_connectionID);
388  return true;
389  }
390 
391  function CommitTrans($ok=true)
392  {
393  if ($this->transOff) return true;
394  if ($this->debug) ADOConnection::outp('<hr>commit transaction');
395  if (!$ok) return $this->RollbackTrans();
396  if ($this->transCnt) $this->transCnt -= 1;
397  sqlsrv_commit($this->_connectionID);
398  return true;
399  }
400  function RollbackTrans()
401  {
402  if ($this->transOff) return true;
403  if ($this->debug) ADOConnection::outp('<hr>rollback transaction');
404  if ($this->transCnt) $this->transCnt -= 1;
405  sqlsrv_rollback($this->_connectionID);
406  return true;
407  }
408 
409  function SetTransactionMode( $transaction_mode )
410  {
411  $this->_transmode = $transaction_mode;
412  if (empty($transaction_mode)) {
413  $this->Execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED');
414  return;
415  }
416  if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
417  $this->Execute("SET TRANSACTION ".$transaction_mode);
418  }
419 
420  /*
421  Usage:
422 
423  $this->BeginTrans();
424  $this->RowLock('table1,table2','table1.id=33 and table2.id=table1.id'); # lock row 33 for both tables
425 
426  # some operation on both tables table1 and table2
427 
428  $this->CommitTrans();
429 
430  See http://www.swynk.com/friends/achigrik/SQL70Locks.asp
431  */
432  function RowLock($tables,$where,$col='1 as adodbignore')
433  {
434  if ($col == '1 as adodbignore') $col = 'top 1 null as ignore';
435  if (!$this->transCnt) $this->BeginTrans();
436  return $this->GetOne("select $col from $tables with (ROWLOCK,HOLDLOCK) where $where");
437  }
438 
439  function SelectDB($dbName)
440  {
441  $this->database = $dbName;
442  $this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions
443  if ($this->_connectionID) {
444  $rs = $this->Execute('USE '.$dbName);
445  if($rs) {
446  return true;
447  } else return false;
448  }
449  else return false;
450  }
451 
452  function ErrorMsg()
453  {
454  $retErrors = sqlsrv_errors(SQLSRV_ERR_ALL);
455  if($retErrors != null) {
456  foreach($retErrors as $arrError) {
457  $this->_errorMsg .= "SQLState: ".$arrError[ 'SQLSTATE']."\n";
458  $this->_errorMsg .= "Error Code: ".$arrError[ 'code']."\n";
459  $this->_errorMsg .= "Message: ".$arrError[ 'message']."\n";
460  }
461  } else {
462  $this->_errorMsg = "No errors found";
463  }
464  return $this->_errorMsg;
465  }
466 
467  function ErrorNo()
468  {
469  $err = sqlsrv_errors(SQLSRV_ERR_ALL);
470  if($err[0]) return $err[0]['code'];
471  else return 0;
472  }
473 
474  // returns true or false
475  function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
476  {
477  if (!function_exists('sqlsrv_connect')) return null;
479  $connectionInfo["Database"]=$argDatabasename;
480  $connectionInfo["UID"]=$argUsername;
481  $connectionInfo["PWD"]=$argPassword;
482 
483  foreach ($this->connectionParameters as $parameter=>$value)
484  $connectionInfo[$parameter] = $value;
485 
486  if ($this->debug) ADOConnection::outp("<hr>connecting... hostname: $argHostname params: ".var_export($connectionInfo,true));
487  //if ($this->debug) ADOConnection::outp("<hr>_connectionID before: ".serialize($this->_connectionID));
488  if(!($this->_connectionID = sqlsrv_connect($argHostname,$connectionInfo))) {
489  if ($this->debug) ADOConnection::outp( "<hr><b>errors</b>: ".print_r( sqlsrv_errors(), true));
490  return false;
491  }
492  //if ($this->debug) ADOConnection::outp(" _connectionID after: ".serialize($this->_connectionID));
493  //if ($this->debug) ADOConnection::outp("<hr>defined functions: <pre>".var_export(get_defined_functions(),true)."</pre>");
494  return true;
495  }
496 
497  // returns true or false
498  function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
499  {
500  //return null;//not implemented. NOTE: Persistent connections have no effect if PHP is used as a CGI program. (FastCGI!)
501  return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
502  }
503 
504  function Prepare($sql)
505  {
506  return $sql; // prepare does not work properly with bind parameters as bind parameters are managed by sqlsrv_prepare!
507 
508  $stmt = sqlsrv_prepare( $this->_connectionID, $sql);
509  if (!$stmt) return $sql;
510  return array($sql,$stmt);
511  }
512 
513  // returns concatenated string
514  // MSSQL requires integers to be cast as strings
515  // automatically cast every datatype to VARCHAR(255)
516  // @author David Rogers (introspectshun)
517  function Concat()
518  {
519  $s = "";
520  $arr = func_get_args();
521 
522  // Split single record on commas, if possible
523  if (sizeof($arr) == 1) {
524  foreach ($arr as $arg) {
525  $args = explode(',', $arg);
526  }
527  $arr = $args;
528  }
529 
530  array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";'));
531  $s = implode('+',$arr);
532  if (sizeof($arr) > 0) return "$s";
533 
534  return '';
535  }
536 
537  /*
538  Unfortunately, it appears that mssql cannot handle varbinary > 255 chars
539  So all your blobs must be of type "image".
540 
541  Remember to set in php.ini the following...
542 
543  ; Valid range 0 - 2147483647. Default = 4096.
544  mssql.textlimit = 0 ; zero to pass through
545 
546  ; Valid range 0 - 2147483647. Default = 4096.
547  mssql.textsize = 0 ; zero to pass through
548  */
549  function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
550  {
551 
552  if (strtoupper($blobtype) == 'CLOB') {
553  $sql = "UPDATE $table SET $column='" . $val . "' WHERE $where";
554  return $this->Execute($sql) != false;
555  }
556  $sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where";
557  return $this->Execute($sql) != false;
558  }
559 
560  // returns query ID if successful, otherwise false
561  function _query($sql,$inputarr=false)
562  {
563  $this->_errorMsg = false;
564 
565  if (is_array($sql)) $sql = $sql[1];
566 
567  $insert = false;
568  // handle native driver flaw for retrieving the last insert ID
569  if(preg_match('/^\W*insert[\s\w()",.]+values\s*\((?:[^;\']|\'\'|(?:(?:\'\')*\'[^\']+\'(?:\'\')*))*;?$/i', $sql)) {
570  $insert = true;
571  $sql .= '; '.$this->identitySQL; // select scope_identity()
572  }
573  if($inputarr) {
574  $rez = sqlsrv_query($this->_connectionID, $sql, $inputarr);
575  } else {
576  $rez = sqlsrv_query($this->_connectionID,$sql);
577  }
578 
579  if ($this->debug) ADOConnection::outp("<hr>running query: ".var_export($sql,true)."<hr>input array: ".var_export($inputarr,true)."<hr>result: ".var_export($rez,true));
580 
581  if(!$rez) {
582  $rez = false;
583  } else if ($insert) {
584  // retrieve the last insert ID (where applicable)
585  while ( sqlsrv_next_result($rez) ) {
586  sqlsrv_fetch($rez);
587  $this->lastInsertID = sqlsrv_get_field($rez, 0);
588  }
589  }
590  return $rez;
591  }
592 
593  // returns true or false
594  function _close()
595  {
596  if ($this->transCnt) $this->RollbackTrans();
597  $rez = @sqlsrv_close($this->_connectionID);
598  $this->_connectionID = false;
599  return $rez;
600  }
601 
602  // mssql uses a default date like Dec 30 2000 12:00AM
603  static function UnixDate($v)
604  {
606  }
607 
608  static function UnixTimeStamp($v)
609  {
611  }
612 
613  function MetaIndexes($table,$primary=false, $owner = false)
614  {
615  $table = $this->qstr($table);
616 
617  $sql = "SELECT i.name AS ind_name, C.name AS col_name, USER_NAME(O.uid) AS Owner, c.colid, k.Keyno,
618  CASE WHEN I.indid BETWEEN 1 AND 254 AND (I.status & 2048 = 2048 OR I.Status = 16402 AND O.XType = 'V') THEN 1 ELSE 0 END AS IsPK,
619  CASE WHEN I.status & 2 = 2 THEN 1 ELSE 0 END AS IsUnique
620  FROM dbo.sysobjects o INNER JOIN dbo.sysindexes I ON o.id = i.id
621  INNER JOIN dbo.sysindexkeys K ON I.id = K.id AND I.Indid = K.Indid
622  INNER JOIN dbo.syscolumns c ON K.id = C.id AND K.colid = C.Colid
623  WHERE LEFT(i.name, 8) <> '_WA_Sys_' AND o.status >= 0 AND O.Name LIKE $table
624  ORDER BY O.name, I.Name, K.keyno";
625 
626  global $ADODB_FETCH_MODE;
627  $save = $ADODB_FETCH_MODE;
628  $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
629  if ($this->fetchMode !== FALSE) {
630  $savem = $this->SetFetchMode(FALSE);
631  }
632 
633  $rs = $this->Execute($sql);
634  if (isset($savem)) {
635  $this->SetFetchMode($savem);
636  }
637  $ADODB_FETCH_MODE = $save;
638 
639  if (!is_object($rs)) {
640  return FALSE;
641  }
642 
643  $indexes = array();
644  while ($row = $rs->FetchRow()) {
645  if (!$primary && $row[5]) continue;
646 
647  $indexes[$row[0]]['unique'] = $row[6];
648  $indexes[$row[0]]['columns'][] = $row[1];
649  }
650  return $indexes;
651  }
652 
653  function MetaForeignKeys($table, $owner=false, $upper=false)
654  {
655  global $ADODB_FETCH_MODE;
656 
657  $save = $ADODB_FETCH_MODE;
658  $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
659  $table = $this->qstr(strtoupper($table));
660 
661  $sql =
662  "select object_name(constid) as constraint_name,
663  col_name(fkeyid, fkey) as column_name,
664  object_name(rkeyid) as referenced_table_name,
665  col_name(rkeyid, rkey) as referenced_column_name
666  from sysforeignkeys
667  where upper(object_name(fkeyid)) = $table
668  order by constraint_name, referenced_table_name, keyno";
669 
670  $constraints =& $this->GetArray($sql);
671 
672  $ADODB_FETCH_MODE = $save;
673 
674  $arr = false;
675  foreach($constraints as $constr) {
676  //print_r($constr);
677  $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3];
678  }
679  if (!$arr) return false;
680 
681  $arr2 = false;
682 
683  foreach($arr as $k => $v) {
684  foreach($v as $a => $b) {
685  if ($upper) $a = strtoupper($a);
686  $arr2[$a] = $b;
687  }
688  }
689  return $arr2;
690  }
691 
692  //From: Fernando Moreira <FMoreira@imediata.pt>
693  function MetaDatabases()
694  {
695  $this->SelectDB("master");
696  $rs =& $this->Execute($this->metaDatabasesSQL);
697  $rows = $rs->GetRows();
698  $ret = array();
699  for($i=0;$i<count($rows);$i++) {
700  $ret[] = $rows[$i][0];
701  }
702  $this->SelectDB($this->database);
703  if($ret)
704  return $ret;
705  else
706  return false;
707  }
708 
709  // "Stein-Aksel Basma" <basma@accelero.no>
710  // tested with MSSQL 2000
711  function MetaPrimaryKeys($table, $owner=false)
712  {
713  global $ADODB_FETCH_MODE;
714 
715  $schema = '';
716  $this->_findschema($table,$schema);
717  if (!$schema) $schema = $this->database;
718  if ($schema) $schema = "and k.table_catalog like '$schema%'";
719 
720  $sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k,
721  information_schema.table_constraints tc
722  where tc.constraint_name = k.constraint_name and tc.constraint_type =
723  'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position ";
724 
725  $savem = $ADODB_FETCH_MODE;
726  $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
727  $a = $this->GetCol($sql);
728  $ADODB_FETCH_MODE = $savem;
729 
730  if ($a && sizeof($a)>0) return $a;
731  $false = false;
732  return $false;
733  }
734 
735 
736  function MetaTables($ttype=false,$showSchema=false,$mask=false)
737  {
738  if ($mask) {
739  $save = $this->metaTablesSQL;
740  $mask = $this->qstr(($mask));
741  $this->metaTablesSQL .= " AND name like $mask";
742  }
743  $ret = ADOConnection::MetaTables($ttype,$showSchema);
744 
745  if ($mask) {
746  $this->metaTablesSQL = $save;
747  }
748  return $ret;
749  }
750  function MetaColumns($table, $upper=true, $schema=false){
751 
752  # start adg
753  static $cached_columns = array();
754  if ($this->cachedSchemaFlush)
755  $cached_columns = array();
756 
757  if (array_key_exists($table,$cached_columns)){
758  return $cached_columns[$table];
759  }
760  # end adg
761 
762  if (!$this->mssql_version)
763  $this->ServerVersion();
764 
765  $this->_findschema($table,$schema);
766  if ($schema) {
767  $dbName = $this->database;
768  $this->SelectDB($schema);
769  }
770  global $ADODB_FETCH_MODE;
771  $save = $ADODB_FETCH_MODE;
772  $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
773 
774  if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
775  $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
776 
777  if ($schema) {
778  $this->SelectDB($dbName);
779  }
780 
781  if (isset($savem)) $this->SetFetchMode($savem);
782  $ADODB_FETCH_MODE = $save;
783  if (!is_object($rs)) {
784  $false = false;
785  return $false;
786  }
787 
788  $retarr = array();
789  while (!$rs->EOF){
790 
791  $fld = new ADOFieldObject();
792  if (array_key_exists(0,$rs->fields)) {
793  $fld->name = $rs->fields[0];
794  $fld->type = $rs->fields[1];
795  $fld->max_length = $rs->fields[2];
796  $fld->precision = $rs->fields[3];
797  $fld->scale = $rs->fields[4];
798  $fld->not_null =!$rs->fields[5];
799  $fld->has_default = $rs->fields[6];
800  $fld->xtype = $rs->fields[7];
801  $fld->type_length = $rs->fields[8];
802  $fld->auto_increment= $rs->fields[9];
803  } else {
804  $fld->name = $rs->fields['name'];
805  $fld->type = $rs->fields['type'];
806  $fld->max_length = $rs->fields['length'];
807  $fld->precision = $rs->fields['precision'];
808  $fld->scale = $rs->fields['scale'];
809  $fld->not_null =!$rs->fields['nullable'];
810  $fld->has_default = $rs->fields['default_value'];
811  $fld->xtype = $rs->fields['xtype'];
812  $fld->type_length = $rs->fields['type_length'];
813  $fld->auto_increment= $rs->fields['is_identity'];
814  }
815 
816  if ($save == ADODB_FETCH_NUM)
817  $retarr[] = $fld;
818  else
819  $retarr[strtoupper($fld->name)] = $fld;
820 
821  $rs->MoveNext();
822 
823  }
824  $rs->Close();
825  # start adg
826  $cached_columns[$table] = $retarr;
827  # end adg
828  return $retarr;
829  }
830 
831 }
832 
833 /*--------------------------------------------------------------------------------------
834  Class Name: Recordset
835 --------------------------------------------------------------------------------------*/
836 
837 class ADORecordset_mssqlnative extends ADORecordSet {
838 
839  var $databaseType = "mssqlnative";
840  var $canSeek = false;
841  var $fieldOffset = 0;
842  // _mths works only in non-localised system
843 
844  function __construct($id,$mode=false)
845  {
846  if ($mode === false) {
847  global $ADODB_FETCH_MODE;
848  $mode = $ADODB_FETCH_MODE;
849 
850  }
851  $this->fetchMode = $mode;
852  return parent::__construct($id,$mode);
853  }
854 
855 
856  function _initrs()
857  {
858  global $ADODB_COUNTRECS;
859  # KMN # if ($this->connection->debug) ADOConnection::outp("(before) ADODB_COUNTRECS: {$ADODB_COUNTRECS} _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}");
860  /*$retRowsAff = sqlsrv_rows_affected($this->_queryID);//"If you need to determine the number of rows a query will return before retrieving the actual results, appending a SELECT COUNT ... query would let you get that information, and then a call to next_result would move you to the "real" results."
861  ADOConnection::outp("rowsaff: ".serialize($retRowsAff));
862  $this->_numOfRows = ($ADODB_COUNTRECS)? $retRowsAff:-1;*/
863  $this->_numOfRows = -1;//not supported
864  $fieldmeta = sqlsrv_field_metadata($this->_queryID);
865  $this->_numOfFields = ($fieldmeta)? count($fieldmeta):-1;
866  # KMN # if ($this->connection->debug) ADOConnection::outp("(after) _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}");
867  /*
868  * Copy the oracle method and cache the metadata at init time
869  */
870  if ($this->_numOfFields>0) {
871  $this->_fieldobjs = array();
872  $max = $this->_numOfFields;
873  for ($i=0;$i<$max; $i++) $this->_fieldobjs[] = $this->_FetchField($i);
874  }
875 
876  }
877 
878 
879  //Contributed by "Sven Axelsson" <sven.axelsson@bokochwebb.se>
880  // get next resultset - requires PHP 4.0.5 or later
881  function NextRecordSet()
882  {
883  if (!sqlsrv_next_result($this->_queryID)) return false;
884  $this->_inited = false;
885  $this->bind = false;
886  $this->_currentRow = -1;
887  $this->Init();
888  return true;
889  }
890 
891  /* Use associative array to get fields array */
892  function Fields($colname)
893  {
894  if ($this->fetchMode != ADODB_FETCH_NUM) return $this->fields[$colname];
895  if (!$this->bind) {
896  $this->bind = array();
897  for ($i=0; $i < $this->_numOfFields; $i++) {
898  $o = $this->FetchField($i);
899  $this->bind[strtoupper($o->name)] = $i;
900  }
901  }
902 
903  return $this->fields[$this->bind[strtoupper($colname)]];
904  }
905 
906  /* Returns: an object containing field information.
907  Get column information in the Recordset object. fetchField() can be used in order to obtain information about
908  fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by
909  fetchField() is retrieved.
910  Designed By jcortinap#jc.com.mx
911  */
912  function _FetchField($fieldOffset = -1)
913  {
914  $_typeConversion = array(
915  -155 => 'datetimeoffset',
916  -154 => 'time',
917  -152 => 'xml',
918  -151 => 'udt',
919  -11 => 'uniqueidentifier',
920  -10 => 'ntext',
921  -9 => 'nvarchar',
922  -8 => 'nchar',
923  -7 => 'bit',
924  -6 => 'tinyint',
925  -5 => 'bigint',
926  -4 => 'image',
927  -3 => 'varbinary',
928  -2 => 'timestamp',
929  -1 => 'text',
930  1 => 'char',
931  2 => 'numeric',
932  3 => 'decimal',
933  4 => 'int',
934  5 => 'smallint',
935  6 => 'float',
936  7 => 'real',
937  12 => 'varchar',
938  91 => 'date',
939  93 => 'datetime'
940  );
941 
942  $fa = @sqlsrv_field_metadata($this->_queryID);
943  if ($fieldOffset != -1) {
944  $fa = $fa[$fieldOffset];
945  }
946  $false = false;
947  if (empty($fa)) {
948  $f = false;//PHP Notice: Only variable references should be returned by reference
949  }
950  else
951  {
952  // Convert to an object
953  $fa = array_change_key_case($fa, CASE_LOWER);
954  $fb = array();
955  if ($fieldOffset != -1)
956  {
957  $fb = array(
958  'name' => $fa['name'],
959  'max_length' => $fa['size'],
960  'column_source' => $fa['name'],
961  'type' => $_typeConversion[$fa['type']]
962  );
963  }
964  else
965  {
966  foreach ($fa as $key => $value)
967  {
968  $fb[] = array(
969  'name' => $value['name'],
970  'max_length' => $value['size'],
971  'column_source' => $value['name'],
972  'type' => $_typeConversion[$value['type']]
973  );
974  }
975  }
976  $f = (object) $fb;
977  }
978  return $f;
979  }
980 
981  /*
982  * Fetchfield copies the oracle method, it loads the field information
983  * into the _fieldobjs array once, to save multiple calls to the
984  * sqlsrv_field_metadata function
985  *
986  * @author KM Newnham
987  * @date 02/20/2013
988  */
989  function FetchField($fieldOffset = -1)
990  {
991  return $this->_fieldobjs[$fieldOffset];
992  }
993 
994  function _seek($row)
995  {
996  return false;//There is no support for cursors in the driver at this time. All data is returned via forward-only streams.
997  }
998 
999  // speedup
1000  function MoveNext()
1001  {
1002  //# KMN # if ($this->connection->debug) ADOConnection::outp("movenext()");
1003  //# KMN # if ($this->connection->debug) ADOConnection::outp("eof (beginning): ".$this->EOF);
1004  if ($this->EOF) return false;
1005 
1006  $this->_currentRow++;
1007  // # KMN # if ($this->connection->debug) ADOConnection::outp("_currentRow: ".$this->_currentRow);
1008 
1009  if ($this->_fetch()) return true;
1010  $this->EOF = true;
1011  //# KMN # if ($this->connection->debug) ADOConnection::outp("eof (end): ".$this->EOF);
1012 
1013  return false;
1014  }
1015 
1016 
1017  // INSERT UPDATE DELETE returns false even if no error occurs in 4.0.4
1018  // also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot!
1019  function _fetch($ignore_fields=false)
1020  {
1021  # KMN # if ($this->connection->debug) ADOConnection::outp("_fetch()");
1022  if ($this->fetchMode & ADODB_FETCH_ASSOC) {
1023  if ($this->fetchMode & ADODB_FETCH_NUM) {
1024  //# KMN # if ($this->connection->debug) ADOConnection::outp("fetch mode: both");
1025  $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_BOTH);
1026  } else {
1027  //# KMN # if ($this->connection->debug) ADOConnection::outp("fetch mode: assoc");
1028  $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_ASSOC);
1029  }
1030 
1031  if (is_array($this->fields)) {
1032  if (ADODB_ASSOC_CASE == 0) {
1033  foreach($this->fields as $k=>$v) {
1034  $this->fields[strtolower($k)] = $v;
1035  }
1036  } else if (ADODB_ASSOC_CASE == 1) {
1037  foreach($this->fields as $k=>$v) {
1038  $this->fields[strtoupper($k)] = $v;
1039  }
1040  }
1041  }
1042  } else {
1043  //# KMN # if ($this->connection->debug) ADOConnection::outp("fetch mode: num");
1044  $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_NUMERIC);
1045  }
1046  if(is_array($this->fields) && array_key_exists(1,$this->fields) && !array_key_exists(0,$this->fields)) {//fix fetch numeric keys since they're not 0 based
1047  $arrFixed = array();
1048  foreach($this->fields as $key=>$value) {
1049  if(is_numeric($key)) {
1050  $arrFixed[$key-1] = $value;
1051  } else {
1052  $arrFixed[$key] = $value;
1053  }
1054  }
1055  //if($this->connection->debug) ADOConnection::outp("<hr>fixing non 0 based return array, old: ".print_r($this->fields,true)." new: ".print_r($arrFixed,true));
1056  $this->fields = $arrFixed;
1057  }
1058  if(is_array($this->fields)) {
1059  foreach($this->fields as $key=>$value) {
1060  if (is_object($value) && method_exists($value, 'format')) {//is DateTime object
1061  $this->fields[$key] = $value->format("Y-m-d\TH:i:s\Z");
1062  }
1063  }
1064  }
1065  if($this->fields === null) $this->fields = false;
1066  # KMN # if ($this->connection->debug) ADOConnection::outp("<hr>after _fetch, fields: <pre>".print_r($this->fields,true)." backtrace: ".adodb_backtrace(false));
1067  return $this->fields;
1068  }
1069 
1070  /* close() only needs to be called if you are worried about using too much memory while your script
1071  is running. All associated result memory for the specified result identifier will automatically be freed. */
1072  function _close()
1073  {
1074  if(is_object($this->_queryID)) {
1075  $rez = sqlsrv_free_stmt($this->_queryID);
1076  $this->_queryID = false;
1077  return $rez;
1078  }
1079  return true;
1080  }
1081 
1082  // mssql uses a default date like Dec 30 2000 12:00AM
1083  static function UnixDate($v)
1084  {
1086  }
1087 
1088  static function UnixTimeStamp($v)
1089  {
1091  }
1092 }
1093 
1094 
1095 class ADORecordSet_array_mssqlnative extends ADORecordSet_array {
1096  function __construct($id=-1,$mode=false)
1097  {
1098  parent::__construct($id,$mode);
1099  }
1100 
1101  // mssql uses a default date like Dec 30 2000 12:00AM
1102  static function UnixDate($v)
1103  {
1104 
1105  if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixDate($v);
1106 
1108 
1109  //Dec 30 2000 12:00AM
1110  if ($ADODB_mssql_date_order == 'dmy') {
1111  if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
1112  return parent::UnixDate($v);
1113  }
1114  if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
1115 
1116  $theday = $rr[1];
1117  $themth = substr(strtoupper($rr[2]),0,3);
1118  } else {
1119  if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
1120  return parent::UnixDate($v);
1121  }
1122  if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
1123 
1124  $theday = $rr[2];
1125  $themth = substr(strtoupper($rr[1]),0,3);
1126  }
1127  $themth = $ADODB_mssql_mths[$themth];
1128  if ($themth <= 0) return false;
1129  // h-m-s-MM-DD-YY
1130  return adodb_mktime(0,0,0,$themth,$theday,$rr[3]);
1131  }
1132 
1133  static function UnixTimeStamp($v)
1134  {
1135 
1136  if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixTimeStamp($v);
1137 
1139 
1140  //Dec 30 2000 12:00AM
1141  if ($ADODB_mssql_date_order == 'dmy') {
1142  if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
1143  ,$v, $rr)) return parent::UnixTimeStamp($v);
1144  if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
1145 
1146  $theday = $rr[1];
1147  $themth = substr(strtoupper($rr[2]),0,3);
1148  } else {
1149  if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
1150  ,$v, $rr)) return parent::UnixTimeStamp($v);
1151  if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
1152 
1153  $theday = $rr[2];
1154  $themth = substr(strtoupper($rr[1]),0,3);
1155  }
1156 
1157  $themth = $ADODB_mssql_mths[$themth];
1158  if ($themth <= 0) return false;
1159 
1160  switch (strtoupper($rr[6])) {
1161  case 'P':
1162  if ($rr[4]<12) $rr[4] += 12;
1163  break;
1164  case 'A':
1165  if ($rr[4]==12) $rr[4] = 0;
1166  break;
1167  default:
1168  break;
1169  }
1170  // h-m-s-MM-DD-YY
1171  return adodb_mktime($rr[4],$rr[5],0,$themth,$theday,$rr[3]);
1172  }
1173 }
1174 
1175 /*
1176 Code Example 1:
1177 
1178 select object_name(constid) as constraint_name,
1179  object_name(fkeyid) as table_name,
1180  col_name(fkeyid, fkey) as column_name,
1181  object_name(rkeyid) as referenced_table_name,
1182  col_name(rkeyid, rkey) as referenced_column_name
1183 from sysforeignkeys
1184 where object_name(fkeyid) = x
1185 order by constraint_name, table_name, referenced_table_name, keyno
1186 
1187 Code Example 2:
1188 select constraint_name,
1189  column_name,
1190  ordinal_position
1191 from information_schema.key_column_usage
1192 where constraint_catalog = db_name()
1193 and table_name = x
1194 order by constraint_name, ordinal_position
1195 
1196 http://www.databasejournal.com/scripts/article.php/1440551
1197 */
ADODB_mssqlnative\$uniqueOrderBy
$uniqueOrderBy
Definition: adodb-mssqlnative.inc.php:124
ADODB_mssqlnative
Definition: adodb-mssqlnative.inc.php:83
ADODB_mssqlnative\MetaIndexes
MetaIndexes($table, $primary=false, $owner=false)
Definition: adodb-mssqlnative.inc.php:613
adodb_mktime
adodb_mktime($hr, $min, $sec, $mon=false, $day=false, $year=false, $is_dst=false, $is_gmt=false)
Definition: adodb-time.inc.php:1246
ADODB_mssqlnative\$fmtDate
$fmtDate
Definition: adodb-mssqlnative.inc.php:87
ADODB_mssqlnative\GenID2008
GenID2008($seq='adodbseq', $start=1)
Definition: adodb-mssqlnative.inc.php:273
ADODB_mssqlnative\MetaColumns
MetaColumns($table, $upper=true, $schema=false)
Definition: adodb-mssqlnative.inc.php:750
ADORecordset_mssqlnative\_seek
_seek($row)
Definition: adodb-mssqlnative.inc.php:994
ADODB_mssqlnative\Prepare
Prepare($sql)
Definition: adodb-mssqlnative.inc.php:504
ADODB_mssqlnative\_affectedrows
_affectedrows()
Definition: adodb-mssqlnative.inc.php:200
ADODB_mssqlnative\$hasTop
$hasTop
Definition: adodb-mssqlnative.inc.php:113
ADODB_mssqlnative\ErrorMsg
ErrorMsg()
Definition: adodb-mssqlnative.inc.php:452
$rs
if(isset($_REQUEST['nrows'])) else $rs
Definition: server.php:94
$sql
$sql
Definition: server.php:84
$ADODB_FETCH_MODE
$ADODB_FETCH_MODE
Definition: functions_db.inc.php:70
ADODB_mssqlnative\$arrayClass
$arrayClass
Definition: adodb-mssqlnative.inc.php:118
ADODB_mssqlnative\_query
_query($sql, $inputarr=false)
Definition: adodb-mssqlnative.inc.php:561
ADODB_mssqlnative\Concat
Concat()
Definition: adodb-mssqlnative.inc.php:517
ADODB_mssqlnative\$metaDatabasesSQL
$metaDatabasesSQL
Definition: adodb-mssqlnative.inc.php:94
ADODB_mssqlnative\$mssql_version
$mssql_version
Definition: adodb-mssqlnative.inc.php:130
ADODB_mssqlnative\RollbackTrans
RollbackTrans()
Definition: adodb-mssqlnative.inc.php:400
ADODB_mssqlnative\CommitTrans
CommitTrans($ok=true)
Definition: adodb-mssqlnative.inc.php:391
ADORecordset_mssqlnative\$canSeek
$canSeek
Definition: adodb-mssqlnative.inc.php:840
ADODB_mssqlnative\_close
_close()
Definition: adodb-mssqlnative.inc.php:594
ADODB_mssqlnative\UnixDate
static UnixDate($v)
Definition: adodb-mssqlnative.inc.php:603
ADODB_mssqlnative\$fmtTimeStamp
$fmtTimeStamp
Definition: adodb-mssqlnative.inc.php:88
ADORecordset_mssqlnative
Definition: adodb-mssqlnative.inc.php:837
ADORecordSet_array_mssqlnative\UnixTimeStamp
static UnixTimeStamp($v)
Definition: adodb-mssqlnative.inc.php:1133
ADORecordset_mssqlnative\MoveNext
MoveNext()
Definition: adodb-mssqlnative.inc.php:1000
$ADODB_mssql_mths
$ADODB_mssql_mths
Definition: adodb-mssqlnative.inc.php:78
ADODB_mssqlnative\$hasAffectedRows
$hasAffectedRows
Definition: adodb-mssqlnative.inc.php:92
ADODB_mssqlnative\$cachedSchemaFlush
$cachedSchemaFlush
Definition: adodb-mssqlnative.inc.php:128
$database
$database
Definition: collate-convert.php:18
ADODB_mssqlnative\MetaDatabases
MetaDatabases()
Definition: adodb-mssqlnative.inc.php:693
ADODB_mssqlnative\_insertid
_insertid()
Definition: adodb-mssqlnative.inc.php:190
ADORecordset_mssqlnative\UnixDate
static UnixDate($v)
Definition: adodb-mssqlnative.inc.php:1083
ADODB_mssqlnative\_connect
_connect($argHostname, $argUsername, $argPassword, $argDatabasename)
Definition: adodb-mssqlnative.inc.php:475
ADODB_mssqlnative\$uniqueSort
$uniqueSort
Definition: adodb-mssqlnative.inc.php:119
ADODB_mssqlnative\MetaForeignKeys
MetaForeignKeys($table, $owner=false, $upper=false)
Definition: adodb-mssqlnative.inc.php:653
ADODB_mssqlnative\$hasInsertID
$hasInsertID
Definition: adodb-mssqlnative.inc.php:89
ADORecordSet_array_mssqlnative\__construct
__construct($id=-1, $mode=false)
Definition: adodb-mssqlnative.inc.php:1096
ADODB_mssqlnative\SelectDB
SelectDB($dbName)
Definition: adodb-mssqlnative.inc.php:439
ADODB_mssqlnative\$sequences
$sequences
Definition: adodb-mssqlnative.inc.php:129
ADORecordset_mssqlnative\Fields
Fields($colname)
Definition: adodb-mssqlnative.inc.php:892
ADODB_mssqlnative\_pconnect
_pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
Definition: adodb-mssqlnative.inc.php:498
ADORecordset_mssqlnative\__construct
__construct($id, $mode=false)
Definition: adodb-mssqlnative.inc.php:844
ADODB_mssqlnative\$rightOuter
$rightOuter
Definition: adodb-mssqlnative.inc.php:121
ADODB_mssqlnative\$connectionInfo
$connectionInfo
Definition: adodb-mssqlnative.inc.php:127
ADODB_mssqlnative\SQLDate
SQLDate($fmt, $col=false)
Definition: adodb-mssqlnative.inc.php:322
ADODB_mssqlnative\$leftOuter
$leftOuter
Definition: adodb-mssqlnative.inc.php:120
ADODB_mssqlnative\$identitySQL
$identitySQL
Definition: adodb-mssqlnative.inc.php:123
ADODB_mssqlnative\BeginTrans
BeginTrans()
Definition: adodb-mssqlnative.inc.php:382
ADODB_mssqlnative\CreateSequence
CreateSequence($seq='adodbseq', $start=1)
Definition: adodb-mssqlnative.inc.php:220
ADORecordset_mssqlnative\_FetchField
_FetchField($fieldOffset=-1)
Definition: adodb-mssqlnative.inc.php:912
ADODB_mssqlnative\ErrorNo
ErrorNo()
Definition: adodb-mssqlnative.inc.php:467
ADODB_mssqlnative\GenID2012
GenID2012($seq='adodbseq', $start=1)
Definition: adodb-mssqlnative.inc.php:298
ADODB_mssqlnative\$dataProvider
$dataProvider
Definition: adodb-mssqlnative.inc.php:85
ADODB_mssqlnative\RowLock
RowLock($tables, $where, $col='1 as adodbignore')
Definition: adodb-mssqlnative.inc.php:432
ADODB_mssqlnative\$hasGenID
$hasGenID
Definition: adodb-mssqlnative.inc.php:114
ADORecordSet_array_mssqlnative
Definition: adodb-mssqlnative.inc.php:1095
ADODB_mssqlnative\MetaTables
MetaTables($ttype=false, $showSchema=false, $mask=false)
Definition: adodb-mssqlnative.inc.php:736
ADODB_mssqlnative\GenID
GenID($seq='adodbseq', $start=1)
Definition: adodb-mssqlnative.inc.php:206
ADODB_mssqlnative\$metaColumnsSQL
$metaColumnsSQL
Definition: adodb-mssqlnative.inc.php:96
ADODB_mssqlnative\$metaTablesSQL
$metaTablesSQL
Definition: adodb-mssqlnative.inc.php:95
ADODB_mssqlnative\MetaPrimaryKeys
MetaPrimaryKeys($table, $owner=false)
Definition: adodb-mssqlnative.inc.php:711
ADODB_mssqlnative\UpdateBlob
UpdateBlob($table, $column, $val, $where, $blobtype='BLOB')
Definition: adodb-mssqlnative.inc.php:549
ADODB_mssqlnative\CreateSequence2012
CreateSequence2012($seq='adodbseq', $start=1)
Definition: adodb-mssqlnative.inc.php:259
ADODB_mssqlnative\$length
$length
Definition: adodb-mssqlnative.inc.php:91
ADODB_mssqlnative\$maxParameterLen
$maxParameterLen
Definition: adodb-mssqlnative.inc.php:117
ADODB_mssqlnative\CreateSequence2008
CreateSequence2008($seq='adodbseq', $start=1)
Definition: adodb-mssqlnative.inc.php:240
ADORecordset_mssqlnative\_fetch
_fetch($ignore_fields=false)
Definition: adodb-mssqlnative.inc.php:1019
ADODB_mssqlnative\$poorAffectedRows
$poorAffectedRows
Definition: adodb-mssqlnative.inc.php:93
ADODB_mssqlnative\$_bindInputArray
$_bindInputArray
Definition: adodb-mssqlnative.inc.php:125
ADODB_mssqlnative\$_dropSeqSQL
$_dropSeqSQL
Definition: adodb-mssqlnative.inc.php:126
ADORecordset_mssqlnative\_close
_close()
Definition: adodb-mssqlnative.inc.php:1072
ADODB_mssqlnative\__construct
__construct()
Definition: adodb-mssqlnative.inc.php:132
$ADODB_COUNTRECS
$ADODB_COUNTRECS
Definition: functions_db.inc.php:34
ADORecordset_mssqlnative\$databaseType
$databaseType
Definition: adodb-mssqlnative.inc.php:839
ADODB_mssqlnative\IfNull
IfNull( $field, $ifNull)
Definition: adodb-mssqlnative.inc.php:185
ADODB_mssqlnative\$replaceQuote
$replaceQuote
Definition: adodb-mssqlnative.inc.php:86
ADORecordset_mssqlnative\$fieldOffset
$fieldOffset
Definition: adodb-mssqlnative.inc.php:841
ADORecordSet_array_mssqlnative\UnixDate
static UnixDate($v)
Definition: adodb-mssqlnative.inc.php:1102
ADODB_mssqlnative\$databaseType
$databaseType
Definition: adodb-mssqlnative.inc.php:84
ADODB_mssqlnative\SetTransactionMode
SetTransactionMode( $transaction_mode)
Definition: adodb-mssqlnative.inc.php:409
$ADODB_mssql_date_order
$ADODB_mssql_date_order
Definition: adodb-mssqlnative.inc.php:77
ADORecordset_mssqlnative\FetchField
FetchField($fieldOffset=-1)
Definition: adodb-mssqlnative.inc.php:989
ADODB_mssqlnative\$substr
$substr
Definition: adodb-mssqlnative.inc.php:90
ADODB_mssqlnative\ServerInfo
ServerInfo()
Definition: adodb-mssqlnative.inc.php:165
ADODB_mssqlnative\ServerVersion
ServerVersion()
Definition: adodb-mssqlnative.inc.php:152
$version
$version
Definition: main.inc.php:22
ADORecordset_mssqlnative\NextRecordSet
NextRecordSet()
Definition: adodb-mssqlnative.inc.php:881
ADODB_mssqlnative\$sysDate
$sysDate
Definition: adodb-mssqlnative.inc.php:115
ADODB_mssqlnative\$sysTimeStamp
$sysTimeStamp
Definition: adodb-mssqlnative.inc.php:116
ADODB_mssqlnative\UnixTimeStamp
static UnixTimeStamp($v)
Definition: adodb-mssqlnative.inc.php:608
ADODB_mssqlnative\$ansiOuter
$ansiOuter
Definition: adodb-mssqlnative.inc.php:122
ADORecordset_mssqlnative\_initrs
_initrs()
Definition: adodb-mssqlnative.inc.php:856
ADORecordset_mssqlnative\UnixTimeStamp
static UnixTimeStamp($v)
Definition: adodb-mssqlnative.inc.php:1088