DDDBL 2.0
 All Classes Namespaces Files Functions Variables
config.inc.php
Go to the documentation of this file.
1 <?php
2 
3 namespace DDDBL;
4 
5 require_once __DIR__ . '/inc/DataObjectPool.class.php';
6 require_once __DIR__ . '/inc/DataObject.class.php';
7 require_once __DIR__ . '/inc/Singleton.class.php';
8 require_once __DIR__ . '/inc/Queue.class.php';
9 
10 require_once __DIR__ . '/inc/exceptions/UnexpectedParameterTypeException.class.php';
11 require_once __DIR__ . '/inc/exceptions/QueryException.class.php';
12 
13 require_once __DIR__ . '/inc/database.func.php';
14 
15 # position of handler, which gets the active database-connection into the queue
16 define('QUEUE_GET_DB_CONNECTION_POSITION', 10);
17 define('QUEUE_GET_QUERY_POSITION', 20);
18 define('QUEUE_BIND_DATA_TYPE_POSITION', 30);
19 define('QUEUE_PREPARE_QUERY_POSITION', 40);
20 define('QUEUE_EXECUTE_QUERY_POSITION', 50);
21 define('QUEUE_FORMAT_RESULT_POSITION', 60);
22 define('QUEUE_CLOSE_CURSOR_POSITION', 70);
23 
24 ###############################################
25 ### set validator for "Database-Definition" ###
26 ###############################################
27 
28 $objDBDefinitionValidator = function ($arrValues) {
29 
30  foreach(array('CONNECTION', 'USER', 'PASS') AS $strDefinitionField)
31  if(!isset($arrValues[$strDefinitionField]) || !is_string($arrValues[$strDefinitionField]))
32  return false;
33 
34  if(isset($arrValues['PDO']) && !is_a($arrValues['PDO'], '\PDO'))
35  return false;
36 
37  return true;
38 
39 };
40 
41 $objDataObjectPool = new DataObjectPool('Database-Definition');
43 
44 ############################################
45 ### set validator for "Query-Definition" ###
46 ############################################
47 
48 $objQueryDefinitionValidator = function ($arrValues) {
49 
50  if(!isset($arrValues['QUERY']) || !is_string($arrValues['QUERY']))
51  return false;
52 
53  if(isset($arrValues['HANDLER']) && !is_string($arrValues['HANDLER']))
54  return false;
55 
56  return true;
57 
58 };
59 
60 $objDataObjectPool = new DataObjectPool('Query-Definition');
62 
63 ##########################################
64 ### set validator for "Result-Handler" ###
65 ##########################################
66 
67 $objResultHandlerValidator = function ($arrValues) {
68 
69  if(!isset($arrValues['HANDLER']) || !is_callable($arrValues['HANDLER']))
70  return false;
71 
72  return true;
73 };
74 
75 $objDataObjectPool = new DataObjectPool('Result-Handler');
77 
78 #########################################
79 ### register queue and result handler ###
80 #########################################
81 
82 require_once __DIR__ . '/handler/register_queue_handler.inc.php';
83 require_once __DIR__ . '/handler/register_result_handler.inc.php';