Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query.php public function getTableInfo($tableName = '', $fetch = '') bug #23

Open
yhuaqiang opened this issue Mar 11, 2017 · 6 comments

Comments

@yhuaqiang
Copy link

2009行.
$result = $this->table($tableName)->find();
if ($result instanceof Model) {
$result = $result->toArray();
}
$fields = array_keys($result);
当集合中数据为空时,$result为null,
导致array_keys($result);抛出异常array_keys() expects parameter 1 to be array, null given
希望修复

@yhuaqiang
Copy link
Author

这个bug是在使用聚合查询的时候出现. 我用的是sum

@cntlis
Copy link

cntlis commented Sep 21, 2019

官方现在都不修复bug的吗?

@liu21st
Copy link
Member

liu21st commented Sep 21, 2019

@cntlis 你怎么知道没修复 很多issue都没有及时关闭而已,mongo扩展都更新换代了好几代了而且 老版本的也不可能一直更新了的

@cntlis
Copy link

cntlis commented Sep 21, 2019

@liu21st 我目前使用的5.0的版本,getTableInfo这里,确实还是会抛错,只不过和他抛错不一样。
Db::connect('db_mongo')
->table('table')
->whereTime('create_time', now())
->find()
我这个样子调用,就会抛错,我一步步的跟踪,最终就是跟踪到了getTableInfo,这里的table函数,没有给table变量赋值,但是也可以另类的去使用,我目前是通过
Db::connect('db_mongo')
->setTable('table')
->table('table')
->whereTime('create_time', now())
->find()
增加了一个setTable函数,实现了变态的用法

@liu21st
Copy link
Member

liu21st commented Sep 22, 2019

table方法本来就不是给table属性赋值的 而是统一走options属性的

@cntlis
Copy link

cntlis commented Sep 22, 2019

@liu21st 那你看我这样的用法有问题不?Db::connect('db_mongo')
->table('table')
->whereTime('create_time', now())
->find()
或者是
Db::connect('db_mongo')
->name('table')
->whereTime('create_time', now())
->find()
我按照文档,按道理应该是没问题的,但是会抛错,抛错就抛错在whereTime这里,他会调用getTable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants