⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Simply get the number of rows



oak
  • profile picture
  • Member

Posted 17 January 2018 - 12:51 PM

Hello,

 

i have not so much experience in OOP.

 

I Would like to query the number of rows to decide if add Button should be visible or not for some users.

 

// Sorry i forgot, it should be shwon in data view page (list of rows)

 

Can someone please help??

 

Thank you.

 

Regards,

Olaf


oak
  • profile picture
  • Member

Posted 17 January 2018 - 15:35 PM

Please, this is very important for me, thank you for your Feedback.


oak
  • profile picture
  • Member

Posted 19 January 2018 - 10:52 AM

thanks for great support


web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 20 January 2018 - 06:01 AM

Hello @oak,

 

In order to achieve your goal you will have to do a manual addition to your CRUD. For example, if you are using Codeigniter, you can do something like this:
 


// Better do this code right before the render function
$tableName = $crud->getTable();
$numRows = $this->db->get($tableName)->num_rows(); // This is codeigniter's query of course you can replace it with a query of your framework

// If number of rows is more than 5 then disable the insert button
if ($numRows > 5) {
    $crud->unsetAdd();
}

$output = $crud->render();

I hope it helped.

 

Regards

Johnny


oak
  • profile picture
  • Member

Posted 20 January 2018 - 08:58 AM

ok thank you, great, i need to learn oop...