PageRenderTime 52ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/libraries/adodb.493a/drivers/adodb-sybase_ase.inc.php

https://github.com/guzzisto/retrospect-gds
PHP | 119 lines | 89 code | 17 blank | 13 comment | 15 complexity | b033a57f859ce74cb50e0104acac6a43 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1
  1. <?php
  2. /*
  3. V4.93 10 Oct 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
  4. Released under both BSD license and Lesser GPL library license.
  5. Whenever there is any discrepancy between the two licenses,
  6. the BSD license will take precedence.
  7. Set tabs to 4.
  8. Contributed by Interakt Online. Thx Cristian MARIN cristic#interaktonline.com
  9. */
  10. require_once ADODB_DIR."/drivers/adodb-sybase.inc.php";
  11. class ADODB_sybase_ase extends ADODB_sybase {
  12. var $databaseType = "sybase_ase";
  13. var $metaTablesSQL="SELECT sysobjects.name FROM sysobjects, sysusers WHERE sysobjects.type='U' AND sysobjects.uid = sysusers.uid";
  14. 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";
  15. 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";
  16. function ADODB_sybase_ase()
  17. {
  18. }
  19. // split the Views, Tables and procedures.
  20. function &MetaTables($ttype=false,$showSchema=false,$mask=false)
  21. {
  22. $false = false;
  23. if ($this->metaTablesSQL) {
  24. // complicated state saving by the need for backward compat
  25. if ($ttype == 'VIEWS'){
  26. $sql = str_replace('U', 'V', $this->metaTablesSQL);
  27. }elseif (false === $ttype){
  28. $sql = str_replace('U',"U' OR type='V", $this->metaTablesSQL);
  29. }else{ // TABLES OR ANY OTHER
  30. $sql = $this->metaTablesSQL;
  31. }
  32. $rs = $this->Execute($sql);
  33. if ($rs === false || !method_exists($rs, 'GetArray')){
  34. return $false;
  35. }
  36. $arr =& $rs->GetArray();
  37. $arr2 = array();
  38. foreach($arr as $key=>$value){
  39. $arr2[] = trim($value['name']);
  40. }
  41. return $arr2;
  42. }
  43. return $false;
  44. }
  45. function MetaDatabases()
  46. {
  47. $arr = array();
  48. if ($this->metaDatabasesSQL!='') {
  49. $rs = $this->Execute($this->metaDatabasesSQL);
  50. if ($rs && !$rs->EOF){
  51. while (!$rs->EOF){
  52. $arr[] = $rs->Fields('name');
  53. $rs->MoveNext();
  54. }
  55. return $arr;
  56. }
  57. }
  58. return false;
  59. }
  60. // fix a bug which prevent the metaColumns query to be executed for Sybase ASE
  61. function &MetaColumns($table,$upper=false)
  62. {
  63. $false = false;
  64. if (!empty($this->metaColumnsSQL)) {
  65. $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
  66. if ($rs === false) return $false;
  67. $retarr = array();
  68. while (!$rs->EOF) {
  69. $fld =& new ADOFieldObject();
  70. $fld->name = $rs->Fields('field_name');
  71. $fld->type = $rs->Fields('type');
  72. $fld->max_length = $rs->Fields('width');
  73. $retarr[strtoupper($fld->name)] = $fld;
  74. $rs->MoveNext();
  75. }
  76. $rs->Close();
  77. return $retarr;
  78. }
  79. return $false;
  80. }
  81. function getProcedureList($schema)
  82. {
  83. return false;
  84. }
  85. function ErrorMsg()
  86. {
  87. if (!function_exists('sybase_connect')){
  88. return 'Your PHP doesn\'t contain the Sybase connection module!';
  89. }
  90. return parent::ErrorMsg();
  91. }
  92. }
  93. class adorecordset_sybase_ase extends ADORecordset_sybase {
  94. var $databaseType = "sybase_ase";
  95. function ADORecordset_sybase_ase($id,$mode=false)
  96. {
  97. $this->ADORecordSet_sybase($id,$mode);
  98. }
  99. }
  100. ?>