| DBX v.1.0 beta - SQL queried XML Database in PHP - User's Manual |
| About DBX | [top] |
| Why DBX was made | [top] |
| How DBX works | [top] |
| How data is stored | [top] |
| Relational Table | in DBX | |||||||||
|
<?xml
version='1.0' encoding='UTF-8'?> <DATABASENAME> <TABLE NAME="tablename" FIELDS="attribute1,attribute2,attribute3"> <RECORD> <attribute1>value1</attribute1> <attribute2>value2</attribute2> <attribute3>value3</attribute3> </RECORD> </TABLE> </DATABASENAME> |
|||||||||
| Copyright & Usage | [top] |
| Installing DBX | [top] |
Please do NOT add a trailing slash.
| Protecting your database | [top] |
| How to use DBX | [top] |
| Available Functions | [top] |
Fetches a result row as an associative array. dbx_query(<SQLquery>)
dbx_fetch_array() fetches one row of data from the result set associated with the specified <queryid>(<queryid> is called SQL result handler). The row is returned as an associative array. Subsequent call to dbx_fetch_array() will return the next row in the result set, or false if there are no more rows.
All the keys used to access data should be in capitals. dbx_fetch_array() returns one row at a time. So, a while loop may be used to access the full result set.
Sends a SQL query. dbx_num_rows(<queryid>)
dbx_query() sends a SQL query to the currently selected database.
dbx_query() returns TRUE (non-zero) or FALSE (zero) to indicate whether or not the query succeeded. A return value of TRUE means that the query was legal and could be executed by DBX. It does not indicate anything about the number of rows affected or returned. It is perfectly possible for a query to succeed but affect no rows or return no rows. In case of a successful select query, dbx_query() returns a SQL result handler, which can be used to fetch data using dbx_fetch_array().
Note that the query string should not end with a semicolon. Also note that all the data items given in the <SQLquery> should be enclosed within single quotes( ' ) only.
See section on Available SQL for list of SQL queries.
Get number of rows in result. dbx_errno()
dbx_num_rows() returns the number of rows in the result set specified by <queryid>. This function is valid only for select queries.
Returns the numerical value of the error message from most recent DBX operation. dbx_error()
Returns the error number from the last DBX operation, or 0 (zero) if no error occurred. Note that this function only returns the error code from the most recently executed DBX function (not including dbx_error() and dbx_errno()), so if you want to use it, make sure you check the value before calling another DBX function.
Returns the text of the error message from most recent DBX operation.All functions return 0 in case of error.
Returns the error text from the last DBX operation, or ' ' (the empty string) if no error occurred. Note that this function only returns the error text from the most recently executed DBX function (not including dbx_error() and dbx_errno()), so if you want to use it, make sure you check the value before calling another DBX function.
| List of Allowed SQL | [top] |
Create a database. select database <databasename>
Creates a directory(database) by the name of <databasename> under the DB directory. Such a directory(database) shouldn't be existing before.
Select a database. create table <tablename>(<fields>)
Selects an existing database <databasename> to work with. All subsequent queries involving tables will look for the tables in the selected database. You need to send this query at least once to work with DBX.
Create a table. drop table <tablename>
Creates a .tab file(table) named <tablename>.tab in the selected database directory. Such a file(table) shouldn't be existing before.
<fields> is a list(seperated by comma) of attributes/fields of the table. Data types and other constraints for the fields may or may not be given. DBX doesn't require them, and will ignore them if given. Also, there is no concept of primary or foreign key. So, they should not be given.
Drop a table. insert into <tablename>[(<fields>)] values(<values>)
Deletes the file(table) named <tablename>.tab from the selected database directory.
Insert a new row. delete from <tablename>[ where <conditions>]
Inserts a new row into table <tablename>. <values> gives the list(seperated by comma) of values to be put in the new row. All data items(both numeric and others) should be enclosed within single quotes( ' ).
<fields> is a list(seperated by comma) used to specify any particular fields/attributes of the table that should be assigned values from <values>. This is optional, if given, values from <values> are assigned only to fields/attributes specified in <fields>, other fields are assigned NULL.
Delete row(s) from a table. update <tablename> set <updates>[ where <conditions>]
Deletes a row or rows from table <tablename>.
<conditions> is optional, if given it deletes only those row(s) which satisfy <conditions>. Otherwise, it deletes all the rows. For detailed rules on how to form <condition> expressions, refer to select query.
Update a table. select <fields> from <tablename>[ where <conditions>][ order by <fields [desc|asc]>]
Modifies the values of attributes/fields in some or all rows of a table <tablename>.
<updates> is a list(seperated by comma) of attributes/fields alongwith their new values.
<updates> like SET attrib1=attrib1*1.1 aren't supported. Also, to set a field's value to NULL, use two consecutive single quotes( '' ).
<conditions> is a simple expression(not nested) which can be used to selectively update some rows that satisfy the <conditions>. This clause is optional, if omitted, update modifies every row. For detailed rules on how to form <condition> expressions, refer to select query.
Retrieve some data. alter table <tablename> add|drop <fields>
Used to retrieve data from table <tablename>. <fields> (after select) may be one of the following three types:
(a) * - This makes DBX to project all fields/attributes present in the table. So the returned rows in the result set have all the fields.(a), (b), (c) can only be used exclusively. Inline mathematical operations in <fields> (after select) like select attrib*1.1 are not supported.
(b) Field names(seperated by comma) - Only specified fields/attributes are projected.
(c) Aggregate functions - They are count, max, min, avg, sum.
<tablename> specifies the table from which data is to be retrieved. Queries spanning multiple tables aren't supported, hence an attempt to do so should not be made.
<conditions> is a simple expression(not nested) which can be used to selectively select some rows that satisfy the <conditions>. This clause is optional, if omitted, all rows are selected. Rules to form <conditions> expression:(a) <conditions> must be a simple expression. Nested expressions aren't allowed.<fields> (after order by) is optional, if omitted it selects rows as they are read. Otherwise, it sorts the selected data by <fields>.
(b) AND or OR keywords can be used to combine two or more conditions in a single <conditions> expression. Alternatively, && or || can also be used.
(c) IS and IS NOT keywords are supported and can be used interchangeably with = and <>(or !=) operators.
(d) NULL keyword is supported. So to signify an empty value either consecutive single quotes( '' ) or NULL can be used. Note that NULL keyword is supported only while forming a <conditions> expression.
(e) LIKE and BETWEEN keywords are not supported. Also, other keywords, unless otherwise mentioned, are not supported.
(f) <conditions> like where attrib4=attrib3*10 are not supported.
<fields> (after order by) is a list(seperated by comma) used to specify any particular fields/attributes according to which the selected data has to be sorted. If you give order by attrib1,attrib2,attrib3 it first sorts the data by attrib1, if any values of attrib1 are same then those rows are sorted by attrib2 and so on. With each field we may also specify the type of sorting i.e. Ascending or Descending, by using asc or desc keywords alongwith each field. If we dont specify the type of sorting, default is ascending (asc).
A successful select query forces dbx_query() to return a SQL result handler, which can be later used to access the result set using dbx_fetch_array() function.
Alter a table.If any error occurs in the execution of a query, dbx_error() returns FALSE(0). Otherwise, it returns TRUE(1). For successful select queries, a SQL Result Handler is returned. This can be later used to access the result set using dbx_fetch_array() function.
Alters the structure of the table <tablename>. By altering the structure, we mean adding or dropping field(s) to or from the table <tablename>.
<fields> is a list(seperated by comma) of attributes/fields of the table that are to be added or dropped. When adding field(s), the value(s) of the newly added field(s) are initialized to NULL.
| More Information Regarding DBX | [top] |
| © 2002 Idya Research. All rights reserved. |