ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:database:text

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v5:database:text [2019/12/31 04:22] – beside the text driver is currently broken, at least make the example consistent with definition/description as intended, typo fixes peterddv5:database:text [2020/01/13 13:17] (current) – fix invalid tag specification dregad
Line 66: Line 66:
 --------------------- ---------------------
 <code php> <code php>
-$rs = $db->execute('select * from table',false,"\$COL1='abc' and \$COL2=3"); +// 3rd parameter is evaled PHP code, not SQL, so watch the '==' vs. '=' 
- +$rs = $db->execute('select * from table', false, "\$COL1=='abc' and \$COL2==3");
-/* +
-* the 3rd param is searched -- make sure that $COL1 is a legal column name +
-*/+
 </code> </code>
  
Line 85: Line 82:
 include 'adodb/adodb.inc.php'; include 'adodb/adodb.inc.php';
  
-$data =  +$data = array(
-array(+
       0=>array(10001,'1953-09-02','Georgi','Facello','M','1986-06-26'),       0=>array(10001,'1953-09-02','Georgi','Facello','M','1986-06-26'),
       1=>array(10002,'1964-06-02','Bezalel','Simmel','F','1985-11-21'),       1=>array(10002,'1964-06-02','Bezalel','Simmel','F','1985-11-21'),
       2=>array(10003,'1959-12-03','Parto','Bamford','M','1986-08-28'),       2=>array(10003,'1959-12-03','Parto','Bamford','M','1986-08-28'),
-      3=>array(10004,'1954-05-01','Chirstian','Koblick','M','1986-12-01'),+      3=>array(10004,'1954-05-01','Christian','Koblick','M','1986-12-01'),
       4=>array(10005,'1955-01-21','Kyoichi','Maliniak', 'M','1989-09-12'),       4=>array(10005,'1955-01-21','Kyoichi','Maliniak', 'M','1989-09-12'),
       5=>array(10006,'1953-04-20','Anneke','Preusig','F','1989-06-02')       5=>array(10006,'1953-04-20','Anneke','Preusig','F','1989-06-02')
 ); );
  
-$cols      = array('EMPNO','BIRTH_DATE','FIRST_NAME','LAST_NAME','SEX','HIRE_DATE');+$cols = array('EMPNO','BIRTH_DATE','FIRST_NAME','LAST_NAME','SEX','HIRE_DATE');
 $metaTypes = array('I','D','C','C','C','D'); $metaTypes = array('I','D','C','C','C','D');
  
Line 104: Line 100:
 $sql = 'select * from table'; $sql = 'select * from table';
  
-$result = $db->execute($sql, "\$EMPNO=10005");+// Does not work with PHP 5.3 or later, see workaround below 
 +$result = $db->execute($sql, false, "\$EMPNO==10005");
  
 while ($r = $result->fetchRow()) { while ($r = $result->fetchRow()) {
Line 110: Line 107:
 } }
 </code> </code>
 +
 +===== Workaround =====
 +
 +For PHP 5.3 or later, the following workaround can be used (tested with ADOdb 5.20.15).
 +
 +Replace the ''$result = $db->execute($sql, false, "\$EMPNO==10005");'' statement in the above sample by the following code.
 +
 +<code php>
 +$db->evalAll = "\$EMPNO==10005";
 +$result = $db->execute($sql);
 +$db->evalAll = false;
 +</code>
 +
 +{{tag>text deprecated}}
v5/database/text.1577762532.txt.gz · Last modified: 2019/12/31 04:22 by peterdd