2424
2525/**
2626 * syslog_db_connect_real - makes a connection to the database server
27- * @param $host - the hostname of the database server, 'localhost' if the database server is running
28- * on this machine
29- *
30- * @param $user - the username to connect to the database server as
31- * @param $pass - the password to connect to the database server with
32- * @param $db_name - the name of the database to connect to
33- * @param $db_type - the type of database server to connect to, only 'mysql' is currently supported
34- * @param $retries - the number a time the server should attempt to connect before failing
35- * @param $db_ssl - true or false, is the database using ssl
36- * @param $db_ssl_key - the path to the ssl key file
37- * @param $db_ssl_cert - the path to the ssl cert file
38- * @param $db_ssl_ca - the path to the ssl ca file
39- *
40- * @return (object) connection_id for success, (bool) '0' for error
27+ *
28+ * @param string $host The hostname of the database server,
29+ * 'localhost' if the database server is running
30+ * on this machine
31+ * @param string $user The username to connect to the database server as
32+ * @param string $pass The password to connect to the database server with
33+ * @param string $db_name The name of the database to connect to
34+ * @param string $db_type The type of database server to connect to, only 'mysql' is currently supported
35+ * @param int $port The database port. Defaults to 3306
36+ * @param int $retries The number a time the server should attempt to connect before failing
37+ * @param bool $db_ssl true or false, is the database using ssl
38+ * @param string $db_ssl_key The path to the ssl key file
39+ * @param string $db_ssl_cert The path to the ssl cert file
40+ * @param string $db_ssl_ca The path to the ssl ca file
41+ *
42+ * @return object|bool connection_id for success, or bool false for error
4143 */
4244function syslog_db_connect_real ($ host , $ user , $ pass , $ db_name , $ db_type , $ port = '3306 ' , $ retries = 20 , $ db_ssl = '' ,
4345 $ db_ssl_key = '' , $ db_ssl_cert = '' , $ db_ssl_ca = '' ) {
@@ -47,9 +49,9 @@ function syslog_db_connect_real($host, $user, $pass, $db_name, $db_type, $port =
4749/**
4850 * syslog_db_close - closes the open connection
4951 *
50- * @param $syslog_cnn - the connection object to connect to
52+ * @param object $syslog_cnn The connection object to connect to
5153 *
52- * @return the result of the close command
54+ * @return bool the result of the close command
5355 */
5456function syslog_db_close ($ syslog_cnn ) {
5557 return db_close ($ syslog_cnn );
@@ -58,193 +60,210 @@ function syslog_db_close($syslog_cnn) {
5860/**
5961 * syslog_db_execute - run an sql query and do not return any output
6062 *
61- * @param $syslog_cnn - the connection object to connect to
62- * @param $sql - the sql query to execute
63- * @param $log - whether to log error messages, defaults to true
63+ * @param string $sql The sql query to execute
64+ * @param bool $log Whether to log error messages, defaults to true
6465 *
65- * @return '1' for success, '0' for error
66+ * @return int 1 for success, 0 for error
6667 */
67- function syslog_db_execute ($ sql , $ log = TRUE ) {
68+ function syslog_db_execute ($ sql , $ log = true ) {
6869 global $ syslog_cnn ;
70+
6971 return db_execute ($ sql , $ log , $ syslog_cnn );
7072}
7173
7274/**
7375 * syslog_db_execute_prepared - run an sql query and do not return any output
7476 *
75- * @param $sql - the sql query to execute
76- * @param $log - whether to log error messages, defaults to true
77+ * @param string $sql The sql query to execute
78+ * @param array $parms The sql params for the prepare
79+ * @param bool $log Whether to log error messages, defaults to true
7780 *
7881 * @return '1' for success, '0' for error
7982 */
80- function syslog_db_execute_prepared ($ sql , $ parms = array () , $ log = TRUE ) {
83+ function syslog_db_execute_prepared ($ sql , $ parms = [] , $ log = true ) {
8184 global $ syslog_cnn ;
85+
8286 return db_execute_prepared ($ sql , $ parms , $ log , $ syslog_cnn );
8387}
8488
8589/**
8690 * syslog_db_fetch_cell - run a 'select' sql query and return the first column of the
87- * first row found
91+ * first row found
8892 *
89- * @param $sql - the sql query to execute
90- * @param $log - whether to log error messages, defaults to true
91- * @param $col_name - use this column name instead of the first one
93+ * @param string $sql The sql query to execute
94+ * @param string $col_name Use this column name instead of the first one
95+ * @param bool $log Whether to log error messages, defaults to true
9296 *
93- * @return (bool) the output of the sql query as a single variable
97+ * @return mixed The output of the sql query as a single variable
9498 */
95- function syslog_db_fetch_cell ($ sql , $ col_name = '' , $ log = TRUE ) {
99+ function syslog_db_fetch_cell ($ sql , $ col_name = '' , $ log = true ) {
96100 global $ syslog_cnn ;
101+
97102 return db_fetch_cell ($ sql , $ col_name , $ log , $ syslog_cnn );
98103}
99104
100105/**
101106 * syslog_db_fetch_cell_prepared - run a 'select' sql query and return the first column of the
102- * first row found
107+ * first row found
103108 *
104- * @param $sql - the sql query to execute
105- * @param $params - an array of parameters
106- * @param $col_name - use this column name instead of the first one
107- * @param $log - whether to log error messages, defaults to true
109+ * @param string $sql The sql query to execute
110+ * @param array $params An array of parameters
111+ * @param string $col_name Use this column name instead of the first one
112+ * @param bool $log Whether to log error messages, defaults to true
108113 *
109- * @return (bool) the output of the sql query as a single variable
114+ * @return mixed The output of the sql query as a single variable
110115 */
111- function syslog_db_fetch_cell_prepared ($ sql , $ params = array () , $ col_name = '' , $ log = TRUE ) {
116+ function syslog_db_fetch_cell_prepared ($ sql , $ params = [] , $ col_name = '' , $ log = true ) {
112117 global $ syslog_cnn ;
118+
113119 return db_fetch_cell_prepared ($ sql , $ params , $ col_name , $ log , $ syslog_cnn );
114120}
115121
116122/**
117123 * syslog_db_fetch_row - run a 'select' sql query and return the first row found
118124 *
119- * @param $sql - the sql query to execute
120- * @param $log - whether to log error messages, defaults to true
125+ * @param string $sql The sql query to execute
126+ * @param bool $log Whether to log error messages, defaults to true
121127 *
122- * @return the first row of the result as a hash
128+ * @return array|bool The first row of the result as a hash
123129 */
124- function syslog_db_fetch_row ($ sql , $ log = TRUE ) {
130+ function syslog_db_fetch_row ($ sql , $ log = true ) {
125131 global $ syslog_cnn ;
132+
126133 return db_fetch_row ($ sql , $ log , $ syslog_cnn );
127134}
128135
129136/**
130137 * syslog_db_fetch_row_prepared - run a 'select' sql query and return the first row found
131138 *
132- * @param $sql - the sql query to execute
133- * @param $params - an array of parameters
134- * @param $log - whether to log error messages, defaults to true
139+ * @param string $sql The sql query to execute
140+ * @param array $params An array of parameters
141+ * @param bool $log Whether to log error messages, defaults to true
135142 *
136- * @return the first row of the result as a hash
143+ * @return array|bool The first row of the result as a hash
137144 */
138- function syslog_db_fetch_row_prepared ($ sql , $ params = array () , $ log = TRUE ) {
145+ function syslog_db_fetch_row_prepared ($ sql , $ params = [] , $ log = true ) {
139146 global $ syslog_cnn ;
147+
140148 return db_fetch_row_prepared ($ sql , $ params , $ log , $ syslog_cnn );
141149}
142150
143151/**
144152 * syslog_db_fetch_assoc - run a 'select' sql query and return all rows found
145153 *
146- * @param $sql - the sql query to execute
147- * @param $log - whether to log error messages, defaults to true
154+ * @param string $sql The sql query to execute
155+ * @param bool $log Whether to log error messages, defaults to true
148156 *
149- * @return the entire result set as a multi-dimensional hash
157+ * @return array|bool The entire result set as a multi-dimensional hash
150158 */
151- function syslog_db_fetch_assoc ($ sql , $ log = TRUE ) {
159+ function syslog_db_fetch_assoc ($ sql , $ log = true ) {
152160 global $ syslog_cnn ;
161+
153162 return db_fetch_assoc ($ sql , $ log , $ syslog_cnn );
154163}
155164
156165/**
157166 * syslog_db_fetch_assoc_prepared - run a 'select' sql query and return all rows found
158167 *
159- * @param $sql - the sql query to execute
160- * @param $params - an array of parameters
161- * @param $log - whether to log error messages, defaults to true
168+ * @param string $sql The sql query to execute
169+ * @param array $params An array of parameters
170+ * @param bool $log Whether to log error messages, defaults to true
162171 *
163- * @return the entire result set as a multi-dimensional hash
172+ * @return array|bool The entire result set as a multi-dimensional hash
164173 */
165- function syslog_db_fetch_assoc_prepared ($ sql , $ params = array () , $ log = TRUE ) {
174+ function syslog_db_fetch_assoc_prepared ($ sql , $ params = [] , $ log = true ) {
166175 global $ syslog_cnn ;
176+
167177 return db_fetch_assoc_prepared ($ sql , $ params , $ log , $ syslog_cnn );
168178}
169179
170180/**
171181 * syslog_db_fetch_insert_id - get the last insert_id or auto incriment
172182 *
173- * @param $syslog_cnn - the connection object to connect to
183+ * @param object $syslog_cnn The connection object to connect to
174184 *
175- * @return the id of the last auto incriment row that was created
185+ * @return int The id of the last auto incriment row that was created
176186 */
177187function syslog_db_fetch_insert_id () {
178188 global $ syslog_cnn ;
179- return db_fetch_insert_id ($ syslog_cnn );
189+
190+ return db_fetch_insert_id ($ syslog_cnn );
180191}
181192
182193/**
183194 * syslog_db_replace - replaces the data contained in a particular row
184195 *
185- * @param $table_name - the name of the table to make the replacement in
186- * @param $array_items - an array containing each column -> value mapping in the row
187- * @param $keyCols - the name of the column containing the primary key
188- * @param $autoQuote - whether to use intelligent quoting or not
196+ * @param string $table_name The name of the table to make the replacement in
197+ * @param array $array_items An array containing each column -> value mapping in the row
198+ * @param mixed $keyCols The name of the column containing the primary key
199+ * @param bool $autoQuote Whether to use intelligent quoting or not
189200 *
190- * @return the auto incriment id column (if applicable)
201+ * @return bool The auto incriment id column (if applicable)
191202 */
192203function syslog_db_replace ($ table_name , $ array_items , $ keyCols ) {
193204 global $ syslog_cnn ;
205+
194206 return db_replace ($ table_name , $ array_items , $ keyCols , $ syslog_cnn );
195207}
196208
197209/**
198210 * syslog_sql_save - saves data to an sql table
199211 *
200- * @param $array_items - an array containing each column -> value mapping in the row
201- * @param $table_name - the name of the table to make the replacement in
202- * @param $key_cols - the primary key(s)
212+ * @param array $array_items An array containing each column -> value mapping in the row
213+ * @param string $table_name The name of the table to make the replacement in
214+ * @param mixed $key_cols The primary key(s)
215+ * @param bool $autoinc Is the primary key autoinc
203216 *
204- * @return the auto incriment id column (if applicable)
217+ * @return int The auto incriment id column (if applicable)
205218 */
206219function syslog_sql_save ($ array_items , $ table_name , $ key_cols = 'id ' , $ autoinc = true ) {
207220 global $ syslog_cnn ;
221+
208222 return sql_save ($ array_items , $ table_name , $ key_cols , $ autoinc , $ syslog_cnn );
209223}
210224
211225/**
212226 * syslog_db_table_exists - checks whether a table exists
213227 *
214- * @param $table - the name of the table
215- * @param $log - whether to log error messages, defaults to true
228+ * @param string $table The name of the table
229+ * @param bool $log Whether to log error messages, defaults to true
216230 *
217- * @return ( bool) the output of the sql query as a single variable
231+ * @return bool The output of the sql query as a single variable
218232 */
219233function syslog_db_table_exists ($ table , $ log = true ) {
220234 global $ syslog_cnn ;
221235
222236 preg_match ("/([`]{0,1}(?<database>[\w_]+)[`]{0,1}\.){0,1}[`]{0,1}(?<table>[\w_]+)[`]{0,1}/ " , $ table , $ matches );
237+
223238 if ($ matches !== false && array_key_exists ('table ' , $ matches )) {
224239 $ sql = 'SHOW TABLES LIKE \'' . $ matches ['table ' ] . '\'' ;
240+
225241 return (db_fetch_cell ($ sql , '' , $ log , $ syslog_cnn ) ? true : false );
226242 }
243+
227244 return false ;
228245}
229246
230247function syslog_db_column_exists ($ table , $ column , $ log = true ) {
231248 global $ syslog_cnn ;
249+
232250 return db_column_exists ($ table , $ column , $ log , $ syslog_cnn );
233251}
234252
235253function syslog_db_add_column ($ table , $ column , $ log = true ) {
236254 global $ syslog_cnn ;
255+
237256 return db_add_column ($ table , $ column , $ log , $ syslog_cnn );
238257}
239258
240259/**
241260 * syslog_db_affected_rows - return the number of rows affected by the last transaction
242261 *
243- * @return ( bool|int) The number of rows affected by the last transaction,
244- * or false on error
262+ * @return bool|int The number of rows affected by the last transaction,
263+ * or false on error
245264 */
246265function syslog_db_affected_rows () {
247266 global $ syslog_cnn ;
248- return db_affected_rows ($ syslog_cnn );;
249- }
250267
268+ return db_affected_rows ($ syslog_cnn );
269+ }
0 commit comments