Reading From Database
|
xdd_read([DATABASE-FILE], [ENTRY-ID], {OPTION}, {OPTION}, {OPTION}, {OPTION})
|
[DATABASE-FILE]
Database File Path Location. This field should contain a relative path to either an existing database file, or one to be written. The name or extension of the file is a user choice. Many use .txt files or .db files.
[ENTRY-ID]
Entry identifier used to read, delete and replace entries. This string (text) can contain virtually any text.
{OPTION}
These are the locations of optional commands. They can be interchanged, and given in any order. Here is a list of optional commands for this function, and their properties.
"RV_OVERRIDE"
With this enabled, the system will not remove the entry ID or search string from the returns results. This is very useful when using word search. This will stop the system from removing the word from the results.
"ID_OVERRIDE"
Stops the system from converting the specified ID to <!--ID-->. This is useful when searching for phrases or words instead of a default entry ID.
"NONCASE"
With NONCASE enabled the system will conduct a non-case sensitive search. Otherwise, "test", "TEST" and "tEsT" are seen as different words.
"R_ARRAY"
By default XDD returns read data within a continuous string of text. When you are dealing with multiple entries, it may be desiriable to retrieve the data within an array (Variable containing seperate entries). Enabling R_ARRAY will have the system return the data in an array.
Remote Database Retrieval
By default this is not enabled. But you can enable this feature if your host supports the functions of cURL. This will allow you to retrieve and read entries from remote databases hosted on another server. They must be available through a network connection. If enabled, XDD will automatically attempt to use cURL for a remote database if the database file you specify contains "http://".
Read Formatting
When a entry is read, any <!--XD_RETURN--> tags are converted to Linux RETURN's. Please see Adding To Database for more information on the purpose of this action.
Example Usage:
These are some examples on the usage of this function. You can use these examples as templates for your own application, or in unison with the information above to learn more.
Display all entries within "database.db" which contain <!--Test--> and remove <!--Test--> from the data returned.
|
<?php
echo xdd_read("database.db", "Test");
?>
|
Display all entries within "database.db" which contain <!--Test--> or <!--TEST--> (Non-Case Sensitive) and do not remove <!--Test--> from the data returned.
|
<?php
echo xdd_read("database.db", "Test", "NONCASE", "RV_OVERRIDE");
?>
|
Display all entries within "database.db" which contain "Test" and do not remove "Test" from the data returned.
|
<?php
echo xdd_read("database.db", "Test", "ID_OVERRIDE", "RV_OVERRIDE");
?>
|
Display only first entry found within "database.db" which contains "Test" and do not remove "Test" from the data returned.
|
<?php
$data = xdd_read("database.db", "Test", "ID_OVERRIDE", "RV_OVERRIDE", "R_ARRAY");
echo $data[0];
?>
|
|