GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Notice: Undefined offset: 0 in /var/www/framework-master/libraries/lithium/data/source/Database.php on line 616
Weird, works for me, are you using the last master ?
Yeah, we're gonna need more data...
list($record) = $this->read($query, $options)->data(); on line 616 returns null.
I am using a Postgres database maybe this has something to do with that? There is no problem when the table has rows.
Sorry, still works for me on:
It's weird becase $this->read($query, $options) is a RecordSet. If it wasn't ->data() should have fail. I don't understand how this can happen.
Any chance having the full context of this bug ?
$this->read($query, $options)->data(); returns and empty array here. I will debug some tomorrow.
latest dev branch
It happens with any table/model/query when the resultset is empty.
Need more infos?
Should contain array ('count' => 0), Maybe the SQL failed ?
Can you provide the generated SQL in your case ?
array ('count' => 0)
Ah I found the problem, I was using a group by clause in the query and the query realy didn't return any value.
The group by didn't behave as I was expecting at all. Sooo that would make it my bad -.-'
I can make the correct query with a DISTINCT clause in the count but a quick google tells me that it's not yet supported. Any ideas on that?
Exuses for posting without adequate testing!
Btw, I'm not sure to understand what you mean about the unsupported 'GROUP BY/DISTINCT' feature.
Indeed Model::find('count') doesn't support the GROUP BY clause out of the box, but if you have something like Galleries has many Images a simple:
$galleries = Galleries::find('all', array(
'fields' => array('count("Images"."id") as count'),
'group' => '"Galleries"."id"',
'with' => array('Images')
should give you the number of images in each galleries with PosgreSQL..
Seems the issue has diverged. Feel free to open a new issue with the new problem if this still an issue.