问题
As show at CakePHP 2.1.x - Run a query without any models in AppController I have a query,
$q = "select id from table where id=123";
$db = ConnectionManager::getDataSource('default');
$qr = $db->rawQuery($q);
ok (!), it works... But, how to get my data?? Where the tutorial examples?
I need something like $data = $qr->fetchAll()
method or $id = getMyData($qr)
function.
回答1:
I believe this may be the solution or at least a point in the right direction.
$q = "select id from table where id=123";
$db = ConnectionManager::getDataSource('default');
$myData = $db->query($q);
来源:https://stackoverflow.com/questions/21612950/cake-2-x-retrive-data-from-rawquery