v5:database:text
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
database:text [2015/10/14 16:45] – [Usage] mnewnham | v5:database:text [2019/12/31 04:23] – make example code fit into the wiki page width peterdd | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Plain Text ====== | ====== Plain Text ====== | ||
<WRAP alert> | <WRAP alert> | ||
- | This driver is broken in ADOdb version 5 when used with PHP version 5.3 and up and absent | + | This driver is broken in ADOdb version 5 when used with PHP version 5.3 and up. This is due to the fact that the **execute** method has a non-compliant 3rd argument to it. Absent |
</ | </ | ||
===== Description ===== | ===== Description ===== | ||
- | The '' | + | The '' |
------------------- | ------------------- | ||
<WRAP right box 400px> | <WRAP right box 400px> | ||
Line 17: | Line 17: | ||
==== Parameters ==== | ==== Parameters ==== | ||
=== $dataArray === | === $dataArray === | ||
- | This is a 2 dimensional array of data. Optionally, | + | This is a 2 dimensional array of data. Optionally, |
==== $dataTypes ==== | ==== $dataTypes ==== | ||
- | The optional parameter $dataTypes provides an array of [[dictionary: | + | The optional parameter $dataTypes provides an array of [[v5:dictionary: |
---------------------- | ---------------------- | ||
<WRAP right info 400px> | <WRAP right info 400px> | ||
- | Column names, whether provided in the first row of data or in the '' | + | Column names, whether provided in the first row of data or in the '' |
</ | </ | ||
==== $columnNames ==== | ==== $columnNames ==== | ||
- | If the first row of the data array is not column names, the '' | + | If the first row of the data array is not column names, the '' |
If provided, the number of columns in the 2< | If provided, the number of columns in the 2< | ||
Line 44: | Line 44: | ||
There is partial support for SQL parsing. We process the SQL using the following rules: | There is partial support for SQL parsing. We process the SQL using the following rules: | ||
- | - SQL order by's always work for the first column ordered. Subsequent cols are ignored | + | - SQL ORDER BY's always work for the first column ordered. Subsequent cols are ignored. |
- | - All operations take place on the same table. In fact the FROM clause is ignored, | + | - All operations take place on the same table. In fact the FROM clause is ignored, |
- | - To simplify code, all columns are returned, except when selecting 1 column | + | - To simplify code, all columns are returned, except when selecting 1 column. |
<code php> | <code php> | ||
- | $rs = $db->Execute(' | + | $rs = $db->execute(' |
- | $rs = $db->Execute(' | + | $rs = $db->execute(' |
// sql accepted and processed -- any table name is accepted | // sql accepted and processed -- any table name is accepted | ||
- | $rs = $db->Execute(' | + | $rs = $db->execute(' |
// sql accepted and processed | // sql accepted and processed | ||
</ | </ | ||
- | Where clauses are ignored, but searching with the 3rd parameter of Execute | + | Where clauses are ignored, but searching with the 3rd parameter of execute() |
------------------------ | ------------------------ | ||
<WRAP right important 400px> | <WRAP right important 400px> | ||
- | Using eval may make code susceptible to SQL injection attacks | + | Using eval may make code susceptible to SQL injection attacks. |
</ | </ | ||
==== Using an eval statement ==== | ==== Using an eval statement ==== | ||
- | The 3rd argument to '' | + | The 3rd argument to '' |
--------------------- | --------------------- | ||
<code php> | <code php> | ||
- | $rs = $db->Execute(' | + | $rs = $db->execute(' |
/* | /* | ||
Line 77: | Line 77: | ||
===== Limitations ===== | ===== Limitations ===== | ||
The following SQL operations are not supported: | The following SQL operations are not supported: | ||
- | * Group by, having, other clauses | + | * GROUP BY, HAVING, other clauses |
* Expression columns such as min(), max() | * Expression columns such as min(), max() | ||
* Joins are not permitted | * Joins are not permitted | ||
Line 86: | Line 86: | ||
$data = | $data = | ||
- | array(0=> | + | array( |
- | 1=>Array(10002,' | + | |
- | 2=>Array(10003,' | + | 1=>array(10002,' |
- | 3=>Array(10004,' | + | 2=>array(10003,' |
- | 4=>Array(10005,' | + | 3=>array(10004,' |
- | 5=>Array(10006,' | + | 4=>array(10005,' |
+ | 5=>array(10006,' | ||
); | ); | ||
- | $cols = array(' | + | $cols = array(' |
$metaTypes = array(' | $metaTypes = array(' | ||
- | $db = ADOnewConnection(' | + | $db = ADONewConnection(' |
- | + | $db-> | |
- | $db-> | + | |
$sql = ' | $sql = ' | ||
- | $result = $db-> | + | $result = $db-> |
- | while ($r = $result-> | + | while ($r = $result-> |
print_r($r); | print_r($r); | ||
+ | } | ||
</ | </ |
v5/database/text.txt · Last modified: 2020/01/13 13:17 by dregad