Codeigniter Database Size 3

Asked

Viewed 47 times

0

Good afternoon, you guys! 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 entered, so it does not exceed a certain limit.

Example to understand my doubt: let’s assume that I want, at most, only 100 data in BD. If I want to add one more, this will not be possible because it has exceeded the limit I have established. I thank, from now on, to those who can help.

1 answer

0

Do you need to count the number of records in a table or in the full 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';
}

?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.