easy-swoole / orm

31 stars 27 forks source link

在invoke里面使用count不返回值 #116

Closed dark-walk closed 4 years ago

dark-walk commented 4 years ago

invoke里面操作count

$xxx->where([
                    'tid' => $id,
                    'day' => date('Ymd')
     ])->count();

返回结果为

array(1) {
  [0]=>
  array(1) {
    ["count(`*`)"]=>
    int(123)
  }
}

不能直接返回一个结果值,如123吗 2.invoke里面使用count,

$xxx->where([
                    'tid' => $id,
                    'day' => date('Ymd')
                ])->count('id as count');

在count(里面 as) 整个SQL就不会执行了

xuanyanwow commented 4 years ago
DbManager::getInstance()->invoke(function ($client){
    return Test::invoke($client)->count(); 
});

测试正常,需要自定义别名使用field + all方法完成。