v5:userguide:learn_fields:start_lesson
Differences
This shows you the differences between two versions of the page.
Last revisionBoth sides next revision | |||
v5:userguide:learn_fields:start_lesson [2016/03/17 01:40] – created mnewnham | v5:userguide:learn_fields:start_lesson [2016/03/17 04:22] – mnewnham | ||
---|---|---|---|
Line 2: | Line 2: | ||
~~NOTOC~~ | ~~NOTOC~~ | ||
====== Fields And Fields Objects ====== | ====== Fields And Fields Objects ====== | ||
+ | ===== Formatting Of Returned Data ===== | ||
+ | ADOdb provides a number of methods for controlling returned data. The data may be represented as arrays, both numeric and associative, | ||
+ | |||
+ | |||
+ | In addition to returning recordsets on a row by row basis, ADOdb allows the user to interrogate each row on a field by field basis. | ||
+ | |||
+ | <code php> | ||
+ | /* | ||
+ | * Load the common code | ||
+ | */ | ||
+ | include ' | ||
+ | |||
+ | may | ||
+ | while (!$recordSet-> | ||
+ | |||
+ | $fld = $recordSet-> | ||
+ | $type = $recordSet-> | ||
+ | |||
+ | if ( $type == ' | ||
+ | print $recordSet-> | ||
+ | | ||
+ | . $recordSet-> | ||
+ | | ||
+ | | ||
+ | print $recordSet-> | ||
+ | |||
+ | | ||
+ | |||
+ | } | ||
+ | $recordSet-> | ||
+ | $conn-> | ||
+ | </ | ||
+ | |||
+ | In this example, we check the field type of the second column using [[v5: | ||
+ | |||
+ | name: name of column | ||
+ | type: native field type of column | ||
+ | max_length: maximum length of field. | ||
+ | | ||
+ | Some databases such as MySQL do not return the maximum length of the field correctly. In these cases max_length will be set to -1. | ||
+ | We then use [[v5: | ||
+ | |||
+ | C: character fields that should be shown in a <input type=" | ||
+ | X: TeXt, large text fields that should be shown in a < | ||
+ | B: Blobs, or Binary Large Objects. Typically images. | ||
+ | D: Date field | ||
+ | T: Timestamp field | ||
+ | L: Logical field (boolean or bit-field) | ||
+ | I: Integer field | ||
+ | N: Numeric field. Includes autoincrement, | ||
+ | | ||
+ | R: Serial field. Includes serial, autoincrement integers. | ||
+ | This works for selected databases. | ||
+ | | ||
+ | If the metatype is of type date or timestamp, then we print it using the user defined date format with [[v5: | ||
+ | |||
+ | Another use for '' | ||
+ | |||
+ | ====== Usage ===== | ||
+ | <code php> | ||
+ | /* | ||
+ | * DB Connection assumed | ||
+ | */ | ||
+ | $result = $db-> | ||
+ | $r = $result-> | ||
+ | print $r-> | ||
+ | /* | ||
+ | * Returns: 10 | ||
+ | */ | ||
+ | </ |
v5/userguide/learn_fields/start_lesson.txt · Last modified: 2016/03/18 00:32 by mnewnham