• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
View providing no results, but table has recent entries

[eluser]Bob Puzld[/eluser]
Thanks Chad. I will try that and get back to you.

[eluser]Bob Puzld[/eluser]
Chad, this is the error I get...

string(0) ""

[eluser]Chad Fulton[/eluser]
Okay, this has been a long process just to find out there was no MySQL error!

It turns out, I should have just taken a look at the code. Although, I have to say that I find it a bit suspicious that this supposedly used to work?

In your controller, you have:
$data2 = array('payouts'=>$this->mdlUser->GetPaymentRequests());

and in your model you have

return $query->result_array();

and in your view you have
// ...
var_dump ($payouts->result_array);
// ...
if($payouts->num_rows != 0):
// ...
foreach($payouts->result as $row):
// ...

Notice the problem here?
You're returning an array of results from your model, but in the view you're acting like you've got a query object (although, not really even that, since they ought to be function calls (i.e. $payouts->result_array())

Does this make sense? Here's how to fix it...

In your model:
return $query;

And in your view, fix all of the things that ought to be function calls (num_rows(), result(), result_array(), etc)

That should do it!

[eluser]Bob Puzld[/eluser]
Thanks for your help Chad. I will do as you suggest. Do you think someone tampered with the code? The reason I ask is because this is a friends site and he used to have someone else do his work, but just after he let him go (which happened to be about the same time as the site upgrades) this problem came about. Hmmm...


[eluser]Chad Fulton[/eluser]
Hello again,

I don't know if I would go so far as to suggest tampering; in fact, it may be that these were not functions in the old version of CodeIgniter, but now are.

Here is what (I hope) will be the complete fix, per your original post:

<h1>Payments Requested (&lt;?=$payouts->num_rows(); ?&gt;)</h1>

    echo "<pre>";
    var_dump ($payouts->result_array());
    echo "</pre>";

&lt;? if($payouts->num_rows() != 0): ?&gt;
  <table id="report" cellspacing="0">
  <tr><th>Account Number</th><th>Name</th><th>Address</th><th>Balance</th><th>Amount Requested</th></tr>
  &lt;? $i = 1;
     foreach($payouts->result() as $row): ?&gt;
    <tr &lt;?= alternator('',' class="altrow"') ?&gt;>
      <td>&lt;?=$row->id?&gt;&lt;input type="hidden" name="payout&lt;?=$i?&gt;" value="&lt;?=$row-&gt;payout_id?&gt;" /></td>
      <td>&lt;?=$row->fname.' '.$row->lname?&gt;</td>
      <td>&lt;?= $row->address.'<br />'.$row->city.', '.$row->state.' '.$row->zip?&gt;</td>
  &lt;? ++$i;
     endforeach; ?&gt;
  &lt;input type="hidden" name="num_payouts" value="&lt;?= $payouts-&gt;num_rows() ?&gt;" />
  <p>&lt;input type="submit" value="Pay Requests" /&gt;&lt;/p>
&lt;? else: ?&gt;
  No pending payouts.
&lt;? endif; ?&gt;

function GetPaymentRequests() {
    $this->db->select('users.*, payouts.amount, payouts.id as payout_id');
    $this->db->join('users','payouts.user_id = users.id','INNER');
    $this->db->orderby('date_requested ASC');
    return $this->db->get();

There was nothing wrong with the controller, so you shouldn't have to make any changes to it.

[eluser]Bob Puzld[/eluser]
Thanks Chad. I really appreciate your help. I will try this and let you know the results.


[eluser]Bob Puzld[/eluser]
Chad, I did as you said and unfortunately no change. This is what I get displayed on the view page now...

array(0) {

Then, if I add the var dump into the controller I get the same result...


What do you think? Should I take the horse out and put it down? :-)

Are you in a position to tarball the source up and, along with whatever db create scripts it needs, and share it?

[eluser]Bob Puzld[/eluser]
jedd, do you want all application files or just the 3 files (view, model, controller)? Where would the DB scripts come from?


[quote author="Bob Puzld" date="1256331425"]jedd, do you want all application files or just the 3 files (view, model, controller)? Where would the DB scripts come from?


DB scripts for creating the schema should have been part of the original product (as packaged by your previous programmer).

You could probably just do a DB dump to get the schema, and then remove the records from same - alternatively there may be some MySQL incantation you can mutter that provides the table definitions without any content.

I (we?) just need enough to be able to reproduce the problem - this will be about 3MB of data - it'll be your system directory, and whatever bits of your controller/views/models are needed to reproduce - you can test this by copying across your broken system into a completely separate directory somewhere, changing the config settings there, until you're happy that it accurately reflects your current problem.

Be sure to remove your database credentials etc before packing the thing up. Check also in case you have some SMTP (etc etc) credentials hard coded anywhere too.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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