Using the LIKE clause in a request in cakephp

I am trying to find out if there is such a record in the database before I start and save the record. I searched googled and found that it looked like it should work, but unfortunately not. I am new to cakephp and can "figure out the right request".

$this->Tape->recursive = -1;
$tapeexists = $this->Tape->find('all', array('condition'=>array('Tape.name LIKE'=>'blondie%')));
$this->set('output', $tapeexists);

If I print_r () the results in the view, I see that it just goes and gets all the results in this table, none of which has a name even remotely resembling "blondie"!

+5
source share
1 answer

I think you just made a mistake conditionswhen doing the search:

$tapeexists = $this->Tape->find('all', array('conditions'=>array('Tape.name LIKE'=>'blondie%')));

This should give the expected results.

Tape. , , , , . - isUnique.

+12

All Articles