PageRenderTime 71ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/adodb/drivers/adodb-sybase_ase.inc.php

http://github.com/moodle/moodle
PHP | 120 lines | 88 code | 17 blank | 15 comment | 15 complexity | 03e71d4df7084e8fe508e2bdb87f2b26 MD5 | raw file
Possible License(s): MIT, AGPL-3.0, MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, Apache-2.0, LGPL-2.1, BSD-3-Clause
  1. <?php
  2. /*
  3. @version v5.20.16 12-Jan-2020
  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.
  10. Contributed by Interakt Online. Thx Cristian MARIN cristic#interaktonline.com
  11. */
  12. require_once ADODB_DIR."/drivers/adodb-sybase.inc.php";
  13. class ADODB_sybase_ase extends ADODB_sybase {
  14. var $databaseType = "sybase_ase";
  15. var $metaTablesSQL="SELECT sysobjects.name FROM sysobjects, sysusers WHERE sysobjects.type='U' AND sysobjects.uid = sysusers.uid";
  16. 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";
  17. 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";
  18. function __construct()
  19. {
  20. }
  21. // split the Views, Tables and procedures.
  22. function MetaTables($ttype=false,$showSchema=false,$mask=false)
  23. {
  24. $false = false;
  25. if ($this->metaTablesSQL) {
  26. // complicated state saving by the need for backward compat
  27. if ($ttype == 'VIEWS'){
  28. $sql = str_replace('U', 'V', $this->metaTablesSQL);
  29. }elseif (false === $ttype){
  30. $sql = str_replace('U',"U' OR type='V", $this->metaTablesSQL);
  31. }else{ // TABLES OR ANY OTHER
  32. $sql = $this->metaTablesSQL;
  33. }
  34. $rs = $this->Execute($sql);
  35. if ($rs === false || !method_exists($rs, 'GetArray')){
  36. return $false;
  37. }
  38. $arr = $rs->GetArray();
  39. $arr2 = array();
  40. foreach($arr as $key=>$value){
  41. $arr2[] = trim($value['name']);
  42. }
  43. return $arr2;
  44. }
  45. return $false;
  46. }
  47. function MetaDatabases()
  48. {
  49. $arr = array();
  50. if ($this->metaDatabasesSQL!='') {
  51. $rs = $this->Execute($this->metaDatabasesSQL);
  52. if ($rs && !$rs->EOF){
  53. while (!$rs->EOF){
  54. $arr[] = $rs->Fields('name');
  55. $rs->MoveNext();
  56. }
  57. return $arr;
  58. }
  59. }
  60. return false;
  61. }
  62. // fix a bug which prevent the metaColumns query to be executed for Sybase ASE
  63. function MetaColumns($table,$upper=false)
  64. {
  65. $false = false;
  66. if (!empty($this->metaColumnsSQL)) {
  67. $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
  68. if ($rs === false) return $false;
  69. $retarr = array();
  70. while (!$rs->EOF) {
  71. $fld = new ADOFieldObject();
  72. $fld->name = $rs->Fields('field_name');
  73. $fld->type = $rs->Fields('type');
  74. $fld->max_length = $rs->Fields('width');
  75. $retarr[strtoupper($fld->name)] = $fld;
  76. $rs->MoveNext();
  77. }
  78. $rs->Close();
  79. return $retarr;
  80. }
  81. return $false;
  82. }
  83. function getProcedureList($schema)
  84. {
  85. return false;
  86. }
  87. function ErrorMsg()
  88. {
  89. if (!function_exists('sybase_connect')){
  90. return 'Your PHP doesn\'t contain the Sybase connection module!';
  91. }
  92. return parent::ErrorMsg();
  93. }
  94. }
  95. class adorecordset_sybase_ase extends ADORecordset_sybase {
  96. var $databaseType = "sybase_ase";
  97. function __construct($id,$mode=false)
  98. {
  99. parent::__construct($id,$mode);
  100. }
  101. }