You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the feature
In order to build an intermediate nested count query, I would like to reuse the built query from a Medoo instance.
Use case: Before returning a paginated list of objects I would like to know the overall number of objects in the database.
I already have a configured Medoo instance which (since complex) I really would like to reuse for the count operation.
The Medoo code for the select is:
$articles = $db->select(
'articles',
$fields,
$where
);
// SELECT (...) FROM articles // where, having, group
A Medoo code for the count could look like this:
$query = $db->getSql( // <-- new method'articles',
$fields,
$where
);
$count = intval($db->query('SELECT COUNT(*) from (' . $query . ') tmp')->fetchColumn());
// SELECT COUNT(*) FROM (// SELECT COUNT(...) FROM articles // where, having, group// ) AS tmp
Information
Version of Medoo: "version": "v1.7.10"
Type of Database (MySQL, MSSQL, SQLite...): MySQL
System (Liunx\Windows\Mac): Linux
Workaround
I am already able to subclass Medoo to provide such getSql() method like this:
Describe the feature
In order to build an intermediate nested count query, I would like to reuse the built query from a Medoo instance.
Use case: Before returning a paginated list of objects I would like to know the overall number of objects in the database.
I already have a configured Medoo instance which (since complex) I really would like to reuse for the count operation.
The Medoo code for the select is:
A Medoo code for the count could look like this:
Information
Workaround
I am already able to subclass Medoo to provide such
getSql()
method like this:Alternative feature
Alternatively, it would be great to pass a
Medoo
or aMedoo::raw
or an sql-string to the$db->count()
method.The text was updated successfully, but these errors were encountered: