• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple way of dumping rows to view?

Been using CodeIgniter for about 24 hours... so forgive me if this is a stupid question.

Been following the excellent CodeIgniter From Scratch screencasts by Jeffrey Way, and following his example, have created a controller + model + view that allows me to retrieve data from my database using Active Rows, and loop through them in the view. Now this is where it's a bit tedious... I want to display the entire row of data, not just a single field - and there's 13 fields in my table. Currently the code in the view looks like:

<?php foreach($records as $row) : ?>
    <?php echo $row->title; ?>
<?php endforeach; ?>

...which gives me the "title" field value... but is there a helper etc that will quickly dump out the entire row's values without having to do something like:

<?php foreach($records as $row) : ?>
    <?php echo $row->title; ?>, <?php echo $row->author; ?>, <?php echo $row->etc; ?>
<?php endforeach; ?>

I'm very much in prototype stage, and for now I just need to dump entire rows of data into views as I build up the framework of my application.


There is no helper to my knowlegde but if you use result_array() instead of result(), you can do an extra foreach to print out all the field.

Hey there,

The simplest way that I can think of is using
(I don't know any helper either %-P ). However, you will still have to use the for construct. But would be as simple as this,


print_r($arr) will simply dump your array on the screen.

Welcome to CodeIgniter!

This may or may not be flexible enough for you, but you can pretty much just dump an Active Record query to the table class to view it. See the manual.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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