Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

   1  <?php
   2  /*
   3    @version   v5.21.0  2021-02-27
   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  
  10    Set tabs to 4.
  11  
  12    Contributed by Interakt Online. Thx Cristian MARIN cristic#interaktonline.com
  13  */
  14  
  15  
  16  require_once ADODB_DIR."/drivers/adodb-sybase.inc.php";
  17  
  18  class ADODB_sybase_ase extends ADODB_sybase {
  19   	 var $databaseType = "sybase_ase";
  20  
  21  	  var $metaTablesSQL="SELECT sysobjects.name FROM sysobjects, sysusers WHERE sysobjects.type='U' AND sysobjects.uid = sysusers.uid";
  22  	  var $metaColumnsSQL = "SELECT syscolumns.name AS field_name, systypes.name AS type, systypes.length AS width FROM sysobjects, syscolumns, systypes WHERE sysobjects.name='%s' AND syscolumns.id = sysobjects.id AND systypes.type=syscolumns.type";
  23  	  var $metaDatabasesSQL ="SELECT a.name FROM master.dbo.sysdatabases a, master.dbo.syslogins b WHERE a.suid = b.suid and a.name like '%' and a.name != 'tempdb' and a.status3 != 256  order by 1";
  24  
  25  	 // split the Views, Tables and procedures.
  26  	function MetaTables($ttype=false,$showSchema=false,$mask=false)
  27  	 {
  28  	 	 $false = false;
  29  	 	 if ($this->metaTablesSQL) {
  30  	 	 	 // complicated state saving by the need for backward compat
  31  
  32  	 	 	 if ($ttype == 'VIEWS'){
  33  	 	 	 	 	 	 $sql = str_replace('U', 'V', $this->metaTablesSQL);
  34  	 	 	 }elseif (false === $ttype){
  35  	 	 	 	 	 	 $sql = str_replace('U',"U' OR type='V", $this->metaTablesSQL);
  36  	 	 	 }else{ // TABLES OR ANY OTHER
  37  	 	 	 	 	 	 $sql = $this->metaTablesSQL;
  38  	 	 	 }
  39  	 	 	 $rs = $this->Execute($sql);
  40  
  41  	 	 	 if ($rs === false || !method_exists($rs, 'GetArray')){
  42  	 	 	 	 	 return $false;
  43  	 	 	 }
  44  	 	 	 $arr = $rs->GetArray();
  45  
  46  	 	 	 $arr2 = array();
  47  	 	 	 foreach($arr as $key=>$value){
  48  	 	 	 	 	 $arr2[] = trim($value['name']);
  49  	 	 	 }
  50  	 	 	 return $arr2;
  51  	 	 }
  52  	 	 return $false;
  53  	 }
  54  
  55  	function MetaDatabases()
  56  	 {
  57  	 	 	 $arr = array();
  58  	 	 	 if ($this->metaDatabasesSQL!='') {
  59  	 	 	 	 $rs = $this->Execute($this->metaDatabasesSQL);
  60  	 	 	 	 if ($rs && !$rs->EOF){
  61  	 	 	 	 	 while (!$rs->EOF){
  62  	 	 	 	 	 	 $arr[] = $rs->Fields('name');
  63  	 	 	 	 	 	 $rs->MoveNext();
  64  	 	 	 	 	 }
  65  	 	 	 	 	 return $arr;
  66  	 	 	 	 }
  67  	 	 	 }
  68  	 	 	 return false;
  69  	 }
  70  
  71  	 // fix a bug which prevent the metaColumns query to be executed for Sybase ASE
  72  	function MetaColumns($table,$upper=false)
  73  	 {
  74  	 	 $false = false;
  75  	 	 if (!empty($this->metaColumnsSQL)) {
  76  
  77  	 	 	 $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
  78  	 	 	 if ($rs === false) return $false;
  79  
  80  	 	 	 $retarr = array();
  81  	 	 	 while (!$rs->EOF) {
  82  	 	 	 	 $fld = new ADOFieldObject();
  83  	 	 	 	 $fld->name = $rs->Fields('field_name');
  84  	 	 	 	 $fld->type = $rs->Fields('type');
  85  	 	 	 	 $fld->max_length = $rs->Fields('width');
  86  	 	 	 	 $retarr[strtoupper($fld->name)] = $fld;
  87  	 	 	 	 $rs->MoveNext();
  88  	 	 	 }
  89  	 	 	 $rs->Close();
  90  	 	 	 return $retarr;
  91  	 	 }
  92  	 	 return $false;
  93  	 }
  94  
  95  	function getProcedureList($schema)
  96  	 {
  97  	 	 	 return false;
  98  	 }
  99  
 100  	function ErrorMsg()
 101  	 {
 102  	 	 if (!function_exists('sybase_connect')){
 103  	 	 	 	 return 'Your PHP doesn\'t contain the Sybase connection module!';
 104  	 	 }
 105  	 	 return parent::ErrorMsg();
 106  	 }
 107  }
 108  
 109  class adorecordset_sybase_ase extends ADORecordset_sybase {
 110  	 var $databaseType = "sybase_ase";
 111  }