/[libdata]/branches/pear-db/my2pg/xx_pear_db.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /branches/pear-db/my2pg/xx_pear_db.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 52 by dpavlin, Fri Mar 5 23:38:19 2004 UTC revision 53 by dpavlin, Sat Mar 6 00:33:16 2004 UTC
# Line 26  function xx_connect ( $db_srv, $db_usr, Line 26  function xx_connect ( $db_srv, $db_usr,
26          if (DB::isError($db)) {          if (DB::isError($db)) {
27                  XXX_debug($db->getMessage() ." / ".                  XXX_debug($db->getMessage() ." / ".
28                          $db->getUserInfo() . " / ".                          $db->getUserInfo() . " / ".
29                          $db->getDebugInfo());                          $db->getDebugInfo());
30                  # XXX remove this!                  # XXX remove this!
31                  print $db->getDebugInfo();                  print $db->getDebugInfo();
                   
32                  die($db->getMessage());                  die($db->getMessage());
33          }          }
   
34  }  }
35    
36  function xx_errno() {  function xx_errno() {
# Line 50  function xx_fetch_array ($rs) { Line 48  function xx_fetch_array ($rs) {
48                  return;                  return;
49          }          }
50    
51            $arr = $rs->fetchRow(DB_FETCHMODE_ASSOC, $GLOBALS["xx_element_nr $rs"]);
52    
53          XXX_debug("xx_fetch_array ($rs) row: ".$GLOBALS["xx_element_nr $rs"]);          XXX_debug("xx_fetch_array ($rs) row: ".$GLOBALS["xx_element_nr $rs"]);
54    
         $arr = $rs->fetchRow(DB_FETCHMODE_ASSOC, $GLOBALS["xx_element_nr $rs"]);  
55          $GLOBALS["xx_element_nr $rs"]++;          $GLOBALS["xx_element_nr $rs"]++;
56          return $arr;          return $arr;
57  }  }
# Line 88  function xx_num_rows($rs) { Line 87  function xx_num_rows($rs) {
87          return $num;          return $num;
88  }  }
89    
90  function xx_query($sql, $con = 0) {  function filter_sql($sql) {
         global $db;  
   
         if ($con == 0) {  
                 $con = $db;  
                 XXX_debug("xx_query (fixed conn): $sql");  
         } else {  
                 XXX_debug("xx_query (conn: $con): $sql");  
         }  
91    
92          # PostgreSQL MVC obsoletes usage of lock/unlock in mysql terms          # PostgreSQL MVC obsoletes usage of lock/unlock in mysql terms
93          if (preg_match('/^\s*lock/is', $sql) || preg_match('/^\s*unlock/is', $sql)) {          if (preg_match('/^\s*lock/is', $sql) || preg_match('/^\s*unlock/is', $sql)) {
94                  return 1;                  return;
95          }          }
96    
97          # fix Mysql contact function into something SQL92 compliant          # fix Mysql contact function into something SQL92 compliant
# Line 118  function xx_query($sql, $con = 0) { Line 109  function xx_query($sql, $con = 0) {
109    
110          $sql = preg_replace('/password\(([^\)]+)\)/is', 'md5(\\1)', $sql);          $sql = preg_replace('/password\(([^\)]+)\)/is', 'md5(\\1)', $sql);
111    
112            return $sql;
113    }
114    
115    function xx_query($sql, $con = 0) {
116            global $db;
117    
118            if ($con == 0) {
119                    $con = $db;
120                    XXX_debug("xx_query (fixed conn): $sql");
121            } else {
122                    XXX_debug("xx_query (conn: $con): $sql");
123            }
124    
125            $sql =filter_sql($sql);
126            if (! isset($sql)) {
127                    return;
128            }
129    
130          $GLOBALS["xx_last_sql"] = $sql;          $GLOBALS["xx_last_sql"] = $sql;
131    
132          XXX_debug("xx_query [transformed]: $sql");          XXX_debug("xx_query [transformed]: $sql");
133    
         $GLOBALS["xx_element_nr $ret"] = 0;  
   
134          $ret = $con->query($sql);          $ret = $con->query($sql);
135            xx_iserror($ret);
136    
137          if ($db->isError($ret)) {          $GLOBALS["xx_element_nr $ret"] = 0;
                 #die($db->getUserInfo());  
                 die($db->DebugInfo());  
         }  
138    
139  #       $GLOBALS["pg_last_oid"] = pg_last_oid($ret);  #       $GLOBALS["pg_last_oid"] = pg_last_oid($ret);
140          if ($ret) {          if ($ret) {
# Line 139  function xx_query($sql, $con = 0) { Line 144  function xx_query($sql, $con = 0) {
144          }          }
145  }  }
146    
147    # check for error, if so, die!
148    function xx_iserror($ret, $message = "") {
149            global $db;
150            if ($db->isError($ret)) {
151                    die($message . $ret->getDebugInfo());
152            }
153    }
154    
155    # prepare and execute statement in one function
156    function xx_prepare_execute() {
157            global $db;
158    
159            $args = func_get_args();
160            $sql = array_shift($args);
161    
162            XXX_debug("xx_prepare_execute: $sql [".join("|",$args)."]");
163    
164            $sth = $db->prepare($sql);
165            xx_iserror($sth);
166            $ret = $db->execute($sth, $args);
167            xx_iserror($ret);
168            return $ret;
169    }
170    
171  function xx_data_seek($rs, $element_nr) {  function xx_data_seek($rs, $element_nr) {
172          $GLOBALS["xx_element_nr"] = $element_nr;          $GLOBALS["xx_element_nr"] = $element_nr;
173  }  }

Legend:
Removed from v.52  
changed lines
  Added in v.53

  ViewVC Help
Powered by ViewVC 1.1.26