1 | <?php |
||
29 | abstract class Base extends \csphere\core\service\Drivers |
||
30 | { |
||
31 | /** |
||
32 | * Stores the logger object |
||
33 | **/ |
||
34 | protected $logger = null; |
||
35 | |||
36 | /** |
||
37 | * Stores the database prefix |
||
38 | **/ |
||
39 | protected $prefix = ''; |
||
40 | |||
41 | /** |
||
42 | * Creates the database handler object |
||
43 | * |
||
44 | * @param array $config Configuration details as an array |
||
45 | * |
||
46 | * @return \csphere\core\database\Base |
||
47 | **/ |
||
48 | |||
49 | public function __construct(array $config) |
||
59 | |||
60 | /** |
||
61 | * Logs database queries |
||
62 | * |
||
63 | * @param string $query The database query for this case |
||
64 | * @param array $assoc Array with columns and values |
||
65 | * @param boolean $log Defaults to true which enables log files if used |
||
66 | * |
||
67 | * @return void |
||
68 | **/ |
||
69 | |||
70 | protected function log($query, array $assoc, $log = true) |
||
83 | |||
84 | /** |
||
85 | * Handles errors for the database connection |
||
86 | * |
||
87 | * @param string $query The database query for this case |
||
88 | * @param array $assoc Array with columns and values |
||
89 | * @param string $msg The error message if already known |
||
90 | * @param boolean $more Append query and and data to message |
||
91 | * |
||
92 | * @throws \Exception |
||
93 | * |
||
94 | * @return void |
||
95 | **/ |
||
96 | |||
97 | protected function error($query, array $assoc, $msg = '', $more = true) |
||
123 | |||
124 | /** |
||
125 | * Returns a formatted array with statistics |
||
126 | * |
||
127 | * @return array |
||
128 | **/ |
||
129 | |||
130 | public function info() |
||
148 | |||
149 | /** |
||
150 | * Handle database driver specific transactions |
||
151 | * |
||
152 | * @param string $command One of these strings: begin, commit, rollback |
||
153 | * |
||
154 | * @return boolean |
||
155 | **/ |
||
156 | |||
157 | abstract public function transaction($command); |
||
158 | |||
159 | /** |
||
160 | * Sends a command to the database and gets the affected rows |
||
161 | * |
||
162 | * @param string $prepare Prepared query string with placeholders |
||
163 | * @param array $assoc Array with columns and values |
||
164 | * @param boolean $replace If more than {pre} needs to be replaced |
||
165 | * @param boolean $insertid Return the last insert id instead of a rowcount |
||
166 | * @param boolean $log Defaults to true which enables log files if used |
||
167 | * |
||
168 | * @return integer |
||
169 | **/ |
||
170 | |||
171 | abstract public function exec( |
||
174 | |||
175 | /** |
||
176 | * Sends a query to the database and fetches the result |
||
177 | * |
||
178 | * @param string $prepare Prepared query string with placeholders |
||
179 | * @param array $assoc Array with columns and values |
||
180 | * @param integer $first Number of the first dataset to show |
||
181 | * @param integer $max Number of datasets to show from first on |
||
182 | * |
||
183 | * @return array |
||
184 | **/ |
||
185 | |||
186 | abstract public function query($prepare, array $assoc, $first = 0, $max = 1); |
||
187 | } |
||
188 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.