Welcome Guest, Not a member yet? Register   Sign In
How to call function in viewer
#1

[eluser]MaxEisley[/eluser]
Hello everyone,

i have one for me insoluble problem.

In viewer i have showing my orders and for every order i want to show declaration of car, some typ, number etc..:
Code:
foreach ($orders as $order) {
      $from = date_create($order->Datum);
      $from = date_format($from, "j.n.Y");
      $until = date_create($order->DatumVraceni);
      $until = date_format($until, "j.n.Y");
      $car = $this->data_model->gettargetcar($order->zakazkaID);
      echo '<tr> <td>'.$order->Jmeno.' '.$order->Prijmeni.' - '.$order->Email.'</td> <td>'.$from.'</td> <td>'.$until.'</td> <td>'.$car->Typ.' s '.$car->SPZ.'</td> </tr>';
    }

But in code i want to call function gettargetcar with parameter zakazkaID(english orderID) and then show Typ and SPZ.

I cannot do it in controller because in Controller i don't get zakazkaID, so it must be in viewer, but this code doesnt work.

It writes this: Trying to get property of non-object

Its project for my homework and i need fast help, thanks very much.
#2

[eluser]MaxEisley[/eluser]
No one can help ? Its very important.
#3

[eluser]skiter[/eluser]
ROW from DB is not a Object, then you can't use -> to get values from!

Query row's results are array, and you can use [ ] to get proper data from it.
#4

[eluser]Unknown[/eluser]
This is nice topic to me because whenever i face this problem i just do quickly and see the good result.

<a href="http://radialabsreviews.tumblr.com/">Radialabs</a>
#5

[eluser]InsiteFX[/eluser]
Also you should not be doing all of that in your view!

It should be done in your controller and model!

InsiteFX
#6

[eluser]MaxEisley[/eluser]
InsiteFX: I cant do it in controller, because firstly i need to get $order->zakazkaID for each order and then immediatelly show it, in viewer.
#7

[eluser]toopay[/eluser]
[quote author="MaxEisley" date="1304035883"]
I cannot do it in controller because in Controller i don't get zakazkaID, so it must be in viewer...[/quote]

WHY? WHY? WHY?
#8

[eluser]danmontgomery[/eluser]
Code:
$CI = get_instance();
foreach ($orders as $order) {
// ...
    $car = $CI->data_model->gettargetcar($order->zakazkaID);
// ...
}
#9

[eluser]MaxEisley[/eluser]
noctrum: Thanks for help man, firstly create instance and then replace it with $this, thank you.
#10

[eluser]toopay[/eluser]
@max Eisley

Consider to process the database(request-response) on your controller and model rather than directly in your view file.




Theme © iAndrew 2016 - Forum software by © MyBB