#native_company# #native_desc#
#native_cta#

PHP, XML, XSL, XPATH and Web Services Page 6

By Mashooq Badar
on May 6, 2004

There will be some functions that may be impossible to generate (i.e. application specific helper functions) the generated code can include a static page where you would define these functions manually.
A Datalayer (abstracting the database specific operations)
In PHP the database based functions are vendor specific. If the Content Server is to be able to support multiple database vendors then these database functions need to encapsulated by a uniform API i.e. a datalayer.
The datalayer is implemented by defining an API that all operations in Content Engine would use. Then all we??ll need to do is to change the include file for the API implementation to switch the database. The following are the function definitions for the API.

<?php
// initialise the db environment
function init_db_env () {
    
}
// creates and returns a database connection
function create_connection ($host$username$password) {
    
}

// use a particular database (only needed for some database) the one that don??t it can be // left blank
function use_db($dbname) {
    
}

// close the specified database connection
function close_connection($conn) {
    
}

/* 
Returns the first rows as elements within their column-names as the tag-names
The elements are enclosed in the specified elemName
 */
function get_element($elemName$conn$query) {
    
}

/*
Returns the first rows as elements enclosed within their column-names as the tag-names
The elements are enclosed in the specified elemName. The full list is enclosed in the 
specified listName
*/
function get_element_list($listName$elemName$conn$query) {
        
}

/*
Inserts into the tablename the values specfied by the name/value pairs in the valuemap
*/
function insert_element($tablename$value_map$conn) {
    
}

/*
Executes the specified insert query on the specified connection
*/
function do_insert($conn$query) {
    
}

/*
Update the specified table with the value specified in the value_map and the sellection 
criteria specified in the selection_map using the specified connection
*/
function update_element($tablename$value_map$selection_map$conn) {
    
}

/*
delete from $tablename where $id_field_name=$id_field_value, using the specified connection
*/
function delete_element($tablename$id_field_name$id_field_value$conn) {
    
}
?>

Note: This would only work if the API strictly conforms to the naming conventions defined in the above definition. This would be better enforced using a more object-oriented approach.

1
|
2
|
3
|
4
|
5
|
6
|
7