Answer the question
In order to leave comments, you need to log in
How to return the result of a query in pdo through a function?
There is a function that makes a query to the database
function queryRes($qury_start_num,$sort,$type) {
$pdo = getConnection();
$result = $pdo->query("SELECT * FROM table_products ORDER BY $sort $type $qury_start_num ");
return $result;
}
//возвращается результат
queryRes($qury_start_num,$sort,$type);
if($result->fetchColumn() > 0) {
while ( $res = $result->fetch()) {
echo $res['title'].'<br/>';
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question