Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

PHP Yii

Hi i using Yii to make my website. I just begin to learn it and and always get one error.

'VendorsPhone'=>array(self::HAS_ONE, 'VendorsPhone', 'Id'),

I create 2 table and relations between them

Make code in CGridView

         array(
        'name'=>'Phone',
        'type' => 'raw',
        'value'=>'$data->VendorsPhone->Phone',
        ),

It is working but when for example it did not find anything in Vendors Phone because it is not filled out it show me error.  and stops script. How I can fix it ?

Thank Everyone for help.
0
umaxim
Asked:
umaxim
  • 2
1 Solution
 
Julian HansenCommented:
What was the error you received?
0
 
umaximAuthor Commented:
Invalid argument supplied for foreach()
0
 
Julian HansenCommented:
Ok - if you want us to assist you you need to play ball.

The error refers to a foreach - but the code you posted has no foreach in it.

Can you at least post the code that is causing the problem.
0
 
Ray PaseurCommented:
Please see http://php.net/manual/en/control-structures.foreach.php

Foreach() is an "iterator" intended for use on arrays and objects.  Other data structures can't be used with foreach().  The most common reason for the "invalid argument" message is that the script expected to have an array or object (perhaps something retrieved from a data base query) but instead got a scalar value, such as NULL or FALSE (perhaps because a data base query failed, or succeeded but returned no data).  

If the foreach() statement is part of your code (not part of Yii) we may be able to help once we can see the surrounding code block and your test data.

If the foreach() statement is not part of your code, you may want to go back to the developers of Yii and post a bug report.  You might also want to check the server error logs.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now