Db\Adapter::fetchColumn

public string | ** fetchColumn (string $sqlQuery, [array $placeholders], [int | string $column])

Returns the n’th field of first row in a SQL query result

1
2
3
4
5
6
7
//Getting count of robots
$robotsCount = $connection->fetchColumn("SELECT count(*) FROM robots");
print_r($robotsCount);
 
//Getting name of last edited robot
$robot = $connection->fetchColumn("SELECT id, name FROM robots order by modified desc", 1);
print_r($robot);
doc_Phalcon
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.