v5:userguide:learn_abstraction:using_execute
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
v5:userguide:learn_abstraction:using_execute [2016/03/15 01:29] – created mnewnham | v5:userguide:learn_abstraction:using_execute [2020/01/02 12:03] (current) – ↷ Links adapted because of a move operation dregad | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <- v5: | + | <- v5: |
~~NOTOC~~ | ~~NOTOC~~ | ||
====== Using The Execute Method ====== | ====== Using The Execute Method ====== | ||
The command [[v5: | The command [[v5: | ||
- | ==== Reading Data ==== | + | ===== Reading Data ===== |
- | When used to read the data, the executed command returns a **Query Result**, which can be accessed | + | When used to read the data, the executed command returns a **Query Result** |
<code php> | <code php> | ||
$sql = " | $sql = " | ||
Line 27: | Line 27: | ||
' | ' | ||
) | ) | ||
- | * etc, until then end of file | + | * etc, until the end of file |
*/ | */ | ||
} | } | ||
</ | </ | ||
Once the end of file has been reached, a flag, '' | Once the end of file has been reached, a flag, '' | ||
+ | |||
Other ways of reading the recordset are: | Other ways of reading the recordset are: | ||
Line 42: | Line 43: | ||
^Command^Description| | ^Command^Description| | ||
| [[v5: | | [[v5: | ||
- | | [[v5: | + | | [[v5: |
| [[v5: | | [[v5: | ||
- | | [[v5: | + | | [[v5: |
- | ==== Writing Data ==== | + | ===== Writing Data ===== |
When used to INSERT/ | When used to INSERT/ | ||
Line 63: | Line 64: | ||
</ | </ | ||
- | ==== See Also ==== | + | ===== Limiting The Number Of Returned Rows ===== |
- | [[v5: | + | For large result sets, it is often necessary to limit the number of rows returned to a set number. This might be used, for example in paginated record sets. In order to do this, the ADOdb method |
+ | |||
+ | When reading records, | ||
+ | |||
+ | selectLimit takes 2 parameters, | ||
+ | - The number of records to return | ||
+ | - Optionally, the starting offset. This value is 1 based, i.e. the first record in the table is numbered 1. | ||
+ | |||
+ | <code php> | ||
+ | $sql = " | ||
+ | /* | ||
+ | * Retrieve 10 records, starting at offset 200 | ||
+ | */ | ||
+ | $result = $db-> | ||
+ | </ | ||
+ | |||
+ | ===== Creating A Recordset Filter ===== | ||
+ | |||
+ | A recordset filter pre-processes all the rows in a recordset after retrieval but before we use it. For example, we want to apply the PHP function // | ||
+ | |||
+ | In order to apply the filter, we must include the extra file **rsfilter.inc.php** | ||
+ | |||
+ | <code php> | ||
+ | |||
+ | include_once ' | ||
+ | include_once ' | ||
+ | |||
+ | /* | ||
+ | * ucwords() every element in the recordset | ||
+ | */ | ||
+ | function doUcwords(& | ||
+ | { | ||
+ | | ||
+ | $arr[$k] = ucwords($v); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | $db = newADOConnection(' | ||
+ | $db-> | ||
+ | |||
+ | $rs = $db-> | ||
+ | $rs = rsFilter($rs,' | ||
+ | </ | ||
+ | |||
+ | The [[v5: |
v5/userguide/learn_abstraction/using_execute.1458001758.txt.gz · Last modified: 2017/04/21 11:39 (external edit)