Closed kumy closed 4 years ago
BTW, I've open it here as this is a bug, but technically, I'm thinking about moving this logic in my application from php
down to Postgres
procedural language as as TRIGGER
.
All examples in the docs for countRel
relates to the find()
function. is it incompatible with load()
?
https://github.com/ikkez/f3-cortex#find
// find published #web-design news, sorted by approved user comments
$news->has('tags',array('slug = ?','web-design'));
$news->filter('comments', array('approved = ?',1));
$news->countRel('comments');
$records = $news->find(
array('publish_date <= ? and published = ?', date('Y-m-d'), true),
array('order' => 'count_comments desc')
);
Confirmed with my example, using find()
doesn't raise the error.
$lastPosition = new Move();
$lastPosition->filter('comments', ['type = ?', 1]);
$lastPosition->countRel('comments');
$lastPosition->find();
have you tried the latest dev version or which one are you using?
I'm on 1.6.0
, will test dev
branch…
Unfortunately, same problem.
# composer require ikkez/f3-cortex=dev-master
[…]
- Updating ikkez/f3-cortex (v1.6.0 => dev-master 364caaa): Checking out 364caaa151
PDOStatement: ERROR: bind message supplies 0 parameters, but prepared statement "pdo_stmt_00000007" requires 1
Does it make a difference when you set count_rel first and call filter afterwards?
please check latest commit
please check latest commit
Bad news :disappointed:
- Updating ikkez/f3-cortex dev-master (364caaa => 90dd8b5): Checking out 90dd8b5376
// PDOStatement: ERROR: bind message supplies 0 parameters, but prepared statement "pdo_stmt_00000005" requires 1
Do you need some traces? var_dump
some variables?
Does it make a difference when you set count_rel first and call filter afterwards?
Yes, it does not raise exception. (tested on 90dd8b5376 and 1.6.0)
$lastPosition = new Move();
$lastPosition->countRel('comments');
$lastPosition->filter('comments', ['type = ?', 1]);
$lastPosition->load();
// No exception
Fixed now... you could even add multiple and use different conditions for the count and the filter methods:
$lastPosition->filter('comments', ['type = ?', 1]);
$lastPosition->countRel('comments');
$lastPosition->countRel('comments', 'count_comments_type2', ['type = ?', 2]);
$lastPosition->load();
Here is another one…
When using
filter()
with bind values, followed by acountRel()
, then the filter parameters are not bound.Some simple examples simplified to be displayed here: