Solved

PHP Yii

Posted on 2014-02-20
4
258 Views
Last Modified: 2014-04-01
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
Comment
Question by:umaxim
  • 2
4 Comments
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 39874419
What was the error you received?
0
 
LVL 1

Author Comment

by:umaxim
ID: 39874619
Invalid argument supplied for foreach()
0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 39874857
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
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39876656
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
There is a huge demand for CodeIgniter among the PHP web developers due to its dynamic features and benefits these days. It is one of most popular and agile open source PHP framework for creating robust web applications in PHP web development field.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now