Cake 2.X retrive data from rawQuery

眉间皱痕 提交于 2019-12-12 20:12:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!