Custom query execution in cakephp. I have applied below code.
$conn = ConnectionManager::get('default');
$rs = $conn->query('SELECT * FROM customers');
It gives me blank array though customers
table has 20 records.
Please suggest me some solution.
Thanks.
It's not recommended but somtimes there is no other way! :
You should mention namespace of connection manger
use Cake\\Datasource\\ConnectionManager;
Get/initialize a connection
$conn = ConnectionManager::get('default');
Execute SQL with something like this
$stmt = $conn->execute('SELECT * FROM customers');
Fetch the results
$results = $stmt ->fetchAll('assoc');
See also
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.