Fetching results

When a query has been executed succesfully you can retrieve the result it gave via DAL. The retrieving is simply calling a function to give you either an array, enumerated array or an object of the next row. So if a query gives you 10 rows you can call one of the fetching functions 10 times. The ammount of rows that are returned by the query are kept in rowcount. So looking at the value in this variable gives you how many rows the query returned or affected. Maybe affected sounds strange but when you preform an insert, update or delete query a number of rows get's affected the query. This number is also stored in rowcount. Below you'll find an explanation of the funtions which DAL provide to fetch the result of a query.

Rowcount

As already said before this variable stores the number of rows that where produced as an result of the query. It also contains the number of rows that were affected when you perform an update, insert or delete query.

Fetching the resulting row as an object

When you executed a query which gave a result you can retrieve a row as an object by calling the fetchObject function. When there was an error fetching the result, by example due the fact you passed the last row in the result, NULL is returned. So where the executing functions return true or false this function returns the object or NULL. The errormessage can be found in lastError or is given to you custom error-handler.

object fetchObject(void);

To view this function in action look at the example.

Fetching the resulting row as an associative array

DAL gives you the opportunity to fetch a row from the result as an array. The array is associative, so the names of the field are used as the indexes. When something goes wrong and the result can't be retrieved the function returns NULL. The error is stored in lastError or is given to your custom error-handler.

array fetchArray(void);

To view this function in action look at the example.

Fetching the resulting row as an enumerated array

You can also fetch a row from the result as an indexed array. The array is filled with the field from the result with the first field beginning at index 1, the next at index 2, ... . When something goes wrong the error is stored in lastError or is given to your custom error-handler.

array fetchArray(void);

To view this function in action look at the example.