source: branches/comu-ver2/data/module/adodb/drivers/adodb-sybase_ase.inc.php @ 18701

Revision 18701, 3.2 KB checked in by nanasess, 14 years ago (diff)

Copyright の更新(#601)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • Property svn:mime-type set to text/x-httpd-php
Line 
1<?php
2/*
3  v4.992 10 Nov 2009  (c) 2000-2010 John Lim (jlim#natsoft.com). 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
13
14require_once ADODB_DIR."/drivers/adodb-sybase.inc.php";
15
16class ADODB_sybase_ase extends ADODB_sybase {
17    var $databaseType = "sybase_ase";
18   
19     var $metaTablesSQL="SELECT sysobjects.name FROM sysobjects, sysusers WHERE sysobjects.type='U' AND sysobjects.uid = sysusers.uid";
20     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";
21     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";
22
23    function ADODB_sybase_ase()
24    {
25    }
26   
27    // split the Views, Tables and procedures.
28    function &MetaTables($ttype=false,$showSchema=false,$mask=false)
29    {
30        $false = false;
31        if ($this->metaTablesSQL) {
32            // complicated state saving by the need for backward compat
33           
34            if ($ttype == 'VIEWS'){
35                        $sql = str_replace('U', 'V', $this->metaTablesSQL);
36            }elseif (false === $ttype){
37                        $sql = str_replace('U',"U' OR type='V", $this->metaTablesSQL);
38            }else{ // TABLES OR ANY OTHER
39                        $sql = $this->metaTablesSQL;
40            }
41            $rs = $this->Execute($sql);
42           
43            if ($rs === false || !method_exists($rs, 'GetArray')){
44                    return $false;
45            }
46            $arr =& $rs->GetArray();
47
48            $arr2 = array();
49            foreach($arr as $key=>$value){
50                    $arr2[] = trim($value['name']);
51            }
52            return $arr2;
53        }
54        return $false;
55    }
56
57    function MetaDatabases()
58    {
59            $arr = array();
60            if ($this->metaDatabasesSQL!='') {
61                $rs = $this->Execute($this->metaDatabasesSQL);
62                if ($rs && !$rs->EOF){
63                    while (!$rs->EOF){
64                        $arr[] = $rs->Fields('name');
65                        $rs->MoveNext();
66                    }
67                    return $arr;
68                }
69            }
70            return false;
71    }
72
73    // fix a bug which prevent the metaColumns query to be executed for Sybase ASE
74    function &MetaColumns($table,$upper=false)
75    {
76        $false = false;
77        if (!empty($this->metaColumnsSQL)) {
78       
79            $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
80            if ($rs === false) return $false;
81
82            $retarr = array();
83            while (!$rs->EOF) {
84                $fld =& new ADOFieldObject();
85                $fld->name = $rs->Fields('field_name');
86                $fld->type = $rs->Fields('type');
87                $fld->max_length = $rs->Fields('width');
88                $retarr[strtoupper($fld->name)] = $fld;
89                $rs->MoveNext();
90            }
91            $rs->Close();
92            return $retarr;
93        }
94        return $false;
95    }
96   
97    function getProcedureList($schema)
98    {
99            return false;
100    }
101
102    function ErrorMsg()
103    {
104        if (!function_exists('sybase_connect')){
105                return 'Your PHP doesn\'t contain the Sybase connection module!';
106        }
107        return parent::ErrorMsg(); 
108    }
109}
110
111class adorecordset_sybase_ase extends ADORecordset_sybase {
112var $databaseType = "sybase_ase";
113function ADORecordset_sybase_ase($id,$mode=false)
114    {
115        $this->ADORecordSet_sybase($id,$mode);
116    }
117   
118}
119?>
Note: See TracBrowser for help on using the repository browser.