Merge pull request #7266 from MrPetovan/bug/notices
[friendica.git/.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 $sql
13  * @return array|bool Query array
14  * @throws Exception
15  * @deprecated
16  */
17 function q($sql) {
18         $args = func_get_args();
19         unset($args[0]);
20
21         if (!DBA::$connected) {
22                 return false;
23         }
24
25         $sql = DBA::cleanQuery($sql);
26         $sql = DBA::anyValueFallback($sql);
27
28         $stmt = @vsprintf($sql, $args);
29
30         $ret = DBA::p($stmt);
31
32         if (is_bool($ret)) {
33                 return $ret;
34         }
35
36         $columns = DBA::columnCount($ret);
37
38         $data = DBA::toArray($ret);
39
40         if ((count($data) == 0) && ($columns == 0)) {
41                 return true;
42         }
43
44         return $data;
45 }