Closed web-monster closed 6 years ago
Implemented so:
$Db->update("test",["record_count"=>"##record_count-1"],["id"=>1]);
$Db->select("articles",["##COUNT(*) AS count","id_category"],["AND"=>["is_read"=>0,"is_del"=>0]]);
In medoo.php:
public function quote($string)
{
preg_match('/^\#\#(.*)/', $string, $match);
if(isset($match[1])) {
return $match[1];
}
return $this->pdo->quote($string);
}
protected function column_quote($string)
{
preg_match('/^\#\#(.*)/', $string, $match);
if(isset($match[1])) {
return $match[1];
}
return '"' . str_replace('.', '"."', $string) . '"';
}
Result:
UPDATE "test" SET "record_count" = record_count-1 WHERE "id" = 1
SELECT COUNT(*) AS count,"id_category" FROM "articles" WHERE "is_read" = 0 AND "is_del" = 0
Will be added? ##
I think it have to make more consideration. The syntax is not friendly enough and is will make it more complex.
Make you better. Without this functionality very gutted. I can not even make a few COUNT
Can't we do a count(something) column yet?
Check out the new feature raw object https://medoo.in/api/raw.
Can add extended columns. For example:
It would be cool