]> git.mxchange.org Git - friendica.git/blob - include/dba.php
Don't try to build form for "None" backend.
[friendica.git] / include / dba.php
1 <?php
2
3 use Friendica\Database\DBA;
4
5 /**
6  * @brief execute SQL query with printf style args - deprecated
7  *
8  * Please use the DBA:: functions instead:
9  * DBA::select, DBA::exists, DBA::insert
10  * DBA::delete, DBA::update, DBA::p, DBA::e
11  *
12  * @param $args Query parameters (1 to N parameters of different types)
13  * @return array|bool Query array
14  * @deprecated
15  */
16 function q($sql) {
17         $args = func_get_args();
18         unset($args[0]);
19
20         if (!DBA::$connected) {
21                 return false;
22         }
23
24         $sql = DBA::cleanQuery($sql);
25         $sql = DBA::anyValueFallback($sql);
26
27         $stmt = @vsprintf($sql, $args);
28
29         $ret = DBA::p($stmt);
30
31         if (is_bool($ret)) {
32                 return $ret;
33         }
34
35         $columns = DBA::columnCount($ret);
36
37         $data = DBA::toArray($ret);
38
39         if ((count($data) == 0) && ($columns == 0)) {
40                 return true;
41         }
42
43         return $data;
44 }