• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Query Builder Class - Problem with delete vs foreign key constraint

#1
Hi everyone!

I have this code:
PHP Code:
    /**
     * TODO - Deleta uma permissão do banco de dados
     *
     * @param Int $id
     * @return Bool
     */
    
public static function deletePermission(Int $id): Bool
    
{
        
//define a tabela
        
$builder $_ENV['db']->table(parent::$tabPermissoes);

        
//tenta deletar o item
        
if($builder->delete(['id' => $id]) !== false) return true;
        else return 
false;
    } 

The code is working when delete function returns !== false ... and seeing the docs https://codeigniter.com/user_guide/datab...ete#delete , in case of failure, the delete function would return false. But I'm getting an error, because I have a MySQL foreign key constraint.

I can fix it checking this foreign key constraint first, but the delete function would not returning false?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.