Cake4: Beginner question findAll deletes entries in Database

I try to iterate over array dishsizes.
Debug of line 153 is:

‘unitprice’ => ‘5’,
‘ingredient_id’ => ‘1’,
‘currency_id’ => ‘1’,
‘dishsize_id’ => ‘1’,

When I try to get the ingredient_id with $ingredient_id = intval($dishsize['ingredient_id']); it results in
(int) 1 (result of debug in line 155)

when I run this query:


it deletes all existing entries with ingredient_id=1

If I hardcode the ingredient_id with $ingredient_id=60; the query runs with no problems.

Could this be, because ingredient_id in my database is bigint, and if that is the reason, how can I get this running?

Here is the whole code, that im struggling with

              foreach($dishsizes AS $dishsize) {
                debug($dishsize); //line 153
                $ingredient_id = intval($dishsize['ingredient_id']);
                debug($ingredient_id); //line 155
                $ingredient_id=60; //line 158


Are you sure they are deleted? Or you just get empty result? Did you checked it with another tool in DB? Like mysql from command line or phpMyAdmin?

Also you can check in debug bar what sql are sent to server and check for any ‘DELETE’ statement.

i checked it with phpmyadmin. the entries where deleted.

I can’t think of any reason why find would ever delete records. There’s almost certainly something else in play here.

I agree, that it cant be from the query. i will try to setup a github repisotory, so that the people of cakephp can check it. but i think it is a beginner mistake

Check sql in debug toolbar, also you can turn in sql logging to file in App/config.php

1 Like

i will do this. thanks for help