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

I have the following code:

PHP Code:
foreach($sales_taxes as $line => $sales_tax)
{
    
$builder $this->db->Table('sales_taxes');
    
$builder->insert($sales_tax);


This will reassign the $builder in each iteration of the loop. Is that needed? I don't fully understand how and when the $builder is reset. If I were to call the below code instead would it still run an insert in each iteration?

PHP Code:
$builder $this->db->Table('sales_taxes');

foreach(
$sales_taxes as $line => $sales_tax)
{
    
$builder->insert($sales_tax);

Reply


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



Theme © iAndrew 2016 - Forum software by © MyBB