friendica-github/include/dba.php

45 lines
790 B
PHP
Raw Normal View History

2010-07-01 23:48:07 +00:00
<?php
use Friendica\Database\DBA;
2010-07-01 23:48:07 +00:00
2017-09-15 06:07:34 +00:00
/**
* @brief 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
*
* @param $args Query parameters (1 to N parameters of different types)
* @return array|bool Query array
* @deprecated
2017-09-15 06:07:34 +00:00
*/
function q($sql) {
2017-04-24 06:24:03 +00:00
$args = func_get_args();
unset($args[0]);
if (!DBA::$connected) {
return false;
}
$sql = DBA::cleanQuery($sql);
$sql = DBA::anyValueFallback($sql);
$stmt = @vsprintf($sql, $args);
$ret = DBA::p($stmt);
if (is_bool($ret)) {
return $ret;
}
$columns = DBA::columnCount($ret);
2018-07-21 02:03:40 +00:00
$data = DBA::toArray($ret);
if ((count($data) == 0) && ($columns == 0)) {
return true;
}
return $data;
}