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