Closed BigOHenry closed 6 years ago
I am unable to reproduce it.
try {
$this->db->select("column")->from("table")->fetchSingle();
} catch (Exception $e) {
}
echo dibi::$sql;
// prints SELECT [column] FROM [table] LIMIT 1
I finally found case when its happening:
$this->db
->select("column")
->from("table")
->where("value = ?", 4);
In where
is a column with name value
(keyword), then it will create this sql:
SELECT 'column' FROM table WHERE value = 4;
Still I am unable to reproduce it:
try {
$this->db->select("column")->from("table")->where("value = ?", 4)->fetchSingle();
} catch (Exception $e) {
}
echo dibi::$sql;
// prints SELECT [column] FROM [table] WHERE value = 4 LIMIT 1
Intereting. Did you try it on Postgre?
It is tested with nearly all databases.
Can you paste here your complete code?
@BigOHenry Tested with PostgreSQL 9.6 and 10 and the translation is correct.
$db
->select("column")
->from("table")
->where("value = ?", 4)
->test();
SELECT "column"
FROM "table"
WHERE value = 4
You have a next difference in output. Missing quotes around table
.
Don't you pass Fluent somewhere else to %ex
or %sql
modifiers? If so, you should use %SQL
, not escaping variant. A serialized Fluent is already sanitized.
Description
How to select one column with Dibi Fluent? When i use this code:
I always got this kind of sql:
SELECT 'column' FROM table;
The result is stringcolumn
.I have to use this: