From fb28bb8d3bb01993e83126be028a1dda43422a39 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 24 Sep 2006 17:59:33 +0000 Subject: Adding database folder --- user_guide/database/fields.html | 144 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 user_guide/database/fields.html (limited to 'user_guide/database/fields.html') diff --git a/user_guide/database/fields.html b/user_guide/database/fields.html new file mode 100644 index 000000000..7cf1f9c4e --- /dev/null +++ b/user_guide/database/fields.html @@ -0,0 +1,144 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.1

+
+ + + + + + + + +
+ + + +
+ + + +
+ + +

Field Data

+ + +

Retrieving Field Names

+

Sometimes it's helpful to gather the field names.

+ +

$this->db->field_names();

+

Returns an array containing the field names. You must supply the table name to the function:

+ + +$fields = $this->db->field_names('table_name');

+ +foreach ($fields as $field)
+{
+   echo $field;
+} +
+ + + +

Retrieving Field MetaData

+

Sometimes it's helpful to gather the field names or other metadata, like the column type, max length, etc.

+ +

$this->db->field_data();

+

Returns an array of objects containing field information.

+ +

Note: Not all databases provide meta-data.

+ +

Usage example:

+ + +$fields = $this->db->field_data('table_name');

+ +foreach ($fields as $field)
+{
+   echo $field->name;
+   echo $field->type;
+   echo $field->max_length;
+   echo $field->primary_key;
+} +
+ +

If you have run a query already you can use the result oject instead of supplying the table name:

+ + +$query = $this->db->query("YOUR QUERY");
+$fields = $query->field_data(); +
+ + +

The following data is available from this function if supported by your database:

+ + + + + + + +
+ + + + + + + \ No newline at end of file -- cgit v1.2.3-24-g4f1b