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

(This post was last modified: 11-04-2021, 07:00 AM by objecttothis. Edit Reason: clarity )

@manager, a quick followup. Am I correct in my understanding then that the $builder does not need to be reinstantiated unless the table that the operation is being performed against is being changed?

For example the following code doesn't need a new `$builder = $this->db->table();` reference because the delete() is being run against the same attribute_links table?

PHP Code:
        $builder $this->db->table('attribute_links');
        
$builder->select('definition_type');
        
$builder->where('definition_id'$definition_id);

        
$definition $builder->get('attribute_definitions')->getRow();

        if(
$definition->definition_type != DROPDOWN)
        {
            
$this->db->transStart();

            
$builder->where('item_id');
            
$builder->where('definition_id'$definition_id);
            
$builder->delete();

            
$this->db->transComplete();

            return 
$this->db->transStatus();
        } 
Reply


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



Theme © iAndrew 2016 - Forum software by © MyBB