]> git.mxchange.org Git - friendica.git/blobdiff - include/dba.php
Merge remote-tracking branch 'upstream/develop' into annando/issue8514
[friendica.git] / include / dba.php
index 57a277f3407a8223a45414313e51af785ab466ce..5f633afaaa65328f7087ede40faf130a4e06e637 100644 (file)
@@ -1,35 +1,48 @@
 <?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
 
 use Friendica\Database\DBA;
 
-function dbesc($str) {
-       if (DBA::$connected) {
-               return(DBA::escape($str));
-       } else {
-               return(str_replace("'","\\'",$str));
-       }
-}
-
 /**
- * @brief execute SQL query with printf style args - deprecated
+ * execute SQL query with printf style args - deprecated
  *
- * Please use the dba:: functions instead:
- * dba::select, dba::exists, dba::insert
- * dba::delete, dba::update, dba::p, dba::e
+ * Please use the DBA:: functions instead:
+ * DBA::select, DBA::exists, DBA::insert
+ * DBA::delete, DBA::update, DBA::p, DBA::e
  *
- * @param $args Query parameters (1 to N parameters of different types)
+ * @param $sql
  * @return array|bool Query array
+ * @throws Exception
+ * @deprecated
  */
 function q($sql) {
        $args = func_get_args();
        unset($args[0]);
 
-       if (!DBA::$connected) {
+       if (!DBA::connected()) {
                return false;
        }
 
-       $sql = DBA::clean_query($sql);
-       $sql = DBA::any_value_fallback($sql);
+       $sql = DBA::cleanQuery($sql);
+       $sql = DBA::anyValueFallback($sql);
 
        $stmt = @vsprintf($sql, $args);
 
@@ -41,7 +54,7 @@ function q($sql) {
 
        $columns = DBA::columnCount($ret);
 
-       $data = DBA::inArray($ret);
+       $data = DBA::toArray($ret);
 
        if ((count($data) == 0) && ($columns == 0)) {
                return true;
@@ -49,7 +62,3 @@ function q($sql) {
 
        return $data;
 }
-
-function dba_timer() {
-       return microtime(true);
-}