Database Size with CodeIgniter 3

0

Good afternoon, everyone! How do I know the number of rows in a database using the CodeIgniter 3 framework? I need to control the amount of data to be inserted, so that it does not exceed a certain limit.

Example to understand my doubt: let's suppose I want at most only 100 data in the DB. If I want to add one more, it will not be possible because it has exceeded the limit I set. Thank you in advance for helping.

    
asked by anonymous 24.06.2017 / 18:58

1 answer

0

Do you need to count the number of records in a table or the entire database, all tables? If it is in a specific table:

<?php

public function conta_tabela(){

    $query = $this->db->get('tabela');

    echo 'Existem '.$query->num_rows().' registros nessa tabela';
}

?>
    
25.06.2017 / 00:27