Cakephp 3 : How to give condition in get method? -


i trying give condition in cakephp 3 method, data fetch foreign id not primary key. here have tried below code:

$eventpasswordall = $this->eventpasswordall->get($id, [             'conditions'  => ['event_id'=>$id],             'contain'     => ['events'] ]); 

but showing me data according id(primary key), not event_id. how add condition in methods event_id=my id ?

don't use get, use find. according cakephp 3.0 table api, get method:

returns single record after finding primary key, if no record found method throws exception.

you need use find:

$eventpasswordall = $this->eventpasswordall->find('all', [ // or 'first'     'conditions' => ['event_id' => $id],     'contain'    => ['events'] ]); // or $eventpasswordall = $this->eventpasswordall->find()     ->where(['event_id' => $id])     ->contain(['events']) ; 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -