Welcome Guest, Not a member yet? Register   Sign In
CI4 $this-db->Table() inside foreach or outside
#5

(This post was last modified: 11-04-2021, 11:33 AM by objecttothis.)

(11-04-2021, 06:24 AM)manager Wrote: Second variant is right

(11-04-2021, 11:10 AM)manager Wrote: I don't understand your code , but what i can say (if i understood you correctly) is when you execute insert, update and delete operations in query builder, by default after it resets all your applied data (for example join, where, orderBy, ignore).
All this operation (delete, insert ...) will return builder instance or false if failed.

Sorry, it probably doesn't help that there's an error in the code. I'm converting this open source application from CI3 to 4. Let me simplify it a little.

PHP Code:
$builder $this->db->table('foo_table');
$result $builder->get();    //After this get() call the $builder instance is "reset" and free to use again?

$builder->where('item_id');
$builder->where('definition_id'$definition_id);
$builder->delete();    //This will work just fine as long as I'm wanting to run the delete against the same table? 

Am I correct that if I wanted to run the $builder->delete() against another table I would just need to place $builder = $this->db->table('bar_table'); after the $builder->get() call and before the $builder->where()?
Reply


Messages In This Thread
RE: CI4 $this-db->Table() inside foreach or outside - by objecttothis - 11-04-2021, 11:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB