DataSource Run-Time Property (PHP)

Applies to

Navigator Control, Record Form, EditableGrid Form, Path Control, Directory Form, Label Control, TextBox Control, TextArea Control, Checkbox Control, Image Control, ImageLink Control, DatePicker Control, Hidden Control, ListBox Control, CheckboxList Control, RadioButton Control

Type

object (cls<name>DataSource)

Access

read/write

Syntax

object->DataSource ->...

Description

This property contains a reference to the data source associated with the given object. This data source can be used to perform additional queries and to access query results.
The properties of the DataSource object (SQL, CountSQL, Where, Order) can be changed in the Events code so that the programmer can alter the properties conditionally (e.g. change the SQL query used to retrieve ListBox object's elements).

A programmer can instantiate a new DataSource object by constructing a connection object. Additional queries on this object can be performed in the events code, or the DataSource object's reference can be passed as the connection reference parameter to CCDLookUp function.

Note:The previously used "ds" syntax is retained for compatibility reasons.

Examples

$db = new clsDB<connection_name>();
$db->query("SELECT article_id,article_title FROM articles");
$articles = array();
while ($db->next_record())
{
	$a = array();
	$a["article_id"] = $db->f("article_id");
	$a["article_title"] = $db->f("article_title");
	$articles[] = $a;
}
where <connection_name> is the name of the connection, e.g. for "Intranet" connection the first line of the example should read:
$db = new clsDBIntranet();

Other examples

Dynamically Modify the WHERE and ORDER BY Clauses of a ListBox,
Dynamically Modify the ORDER BY Clause,
Dynamically Modify the SQL Statement,
Dynamically Modify the WHERE Clause

See also

ds Property
CCDLookUp Function
SQL Property
CountSQL Property
Order Property
Where Property
ListBox Object
Grid Form