Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
755 B

11 years ago
11 years ago
  1. <?php
  2. use Friendica\Database\DBA;
  3. /**
  4. * @brief execute SQL query with printf style args - deprecated
  5. *
  6. * Please use the DBA:: functions instead:
  7. * DBA::select, DBA::exists, DBA::insert
  8. * DBA::delete, DBA::update, DBA::p, DBA::e
  9. *
  10. * @param $sql
  11. * @return array|bool Query array
  12. * @throws Exception
  13. * @deprecated
  14. */
  15. function q($sql) {
  16. $args = func_get_args();
  17. unset($args[0]);
  18. if (!DBA::connected()) {
  19. return false;
  20. }
  21. $sql = DBA::cleanQuery($sql);
  22. $sql = DBA::anyValueFallback($sql);
  23. $stmt = @vsprintf($sql, $args);
  24. $ret = DBA::p($stmt);
  25. if (is_bool($ret)) {
  26. return $ret;
  27. }
  28. $columns = DBA::columnCount($ret);
  29. $data = DBA::toArray($ret);
  30. if ((count($data) == 0) && ($columns == 0)) {
  31. return true;
  32. }
  33. return $data;
  34. }