init
[garradin.git] / include / libs / template_lite / plugins / function.db_result_call.php
1 <?php
2 /*
3 * Template Lite plugin
4 * -------------------------------------------------------------
5 * Type: function
6 * Name: db_result_call
7 * Purpose: Interface with ADOdb Lite to return all result elements to assigned variable.
8 *
9 * db_object = Database object
10 * db_function = Database result function to execute
11 * db_result_object = Database result object
12 * db_assign = variable name to assign result data
13 * db_errornumber_assign = variable name to assign the database error number
14 * db_error_assign = the variable name to assign the database error message
15 * db_EOF_assign = the variable name to assign the database end of file flag
16 * -------------------------------------------------------------
17 */
18 function tpl_function_db_result_call($params, &$template_object)
19 {
20 if (empty($params['db_object']))
21 {
22 throw new Template_Exception("db_result_call: missing db_object parameter", $template_object);
23 }
24
25 if (!is_object($params['db_object']))
26 {
27 throw new Template_Exception("db_result_call: db_object isn't an object", $template_object);
28 }
29
30 $db = $params['db_object'];
31
32 if (empty($params['db_result_object']))
33 {
34 throw new Template_Exception("db_result_call: missing db_result_object parameter", $template_object);
35 }
36
37 if (!is_object($params['db_result_object']))
38 {
39 throw new Template_Exception("db_result_call: db_result_object isn't an object", $template_object);
40 }
41
42 $result_object = $params['db_result_object'];
43
44 if (empty($params['db_assign']))
45 {
46 throw new Template_Exception("db_result_call: missing db_assign parameter", $template_object);
47 }
48
49 if (empty($params['db_function']))
50 {
51 throw new Template_Exception("db_result_call: missing db_function parameter", $template_object);
52 }
53
54 $db_function = $params['db_function'];
55
56 $result = $result_object->$db_function();
57
58 $template_object->assign($params['db_assign'], $result);
59
60 if (!empty($params['db_errornumber_assign']))
61 {
62 $template_object->assign($params['db_errornumber_assign'], $db->ErrorNo());
63 }
64
65 if (!empty($params['db_error_assign']))
66 {
67 $template_object->assign($params['db_error_assign'], $db->ErrorMsg());
68 }
69
70 if (!empty($params['db_EOF_assign']))
71 {
72 $template_object->assign($params['db_EOF_assign'], $result_object->EOF);
73 }
74 }
75 ?>