Solved

PHP Yii

Posted on 2014-02-20
4
264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 57

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 57

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 110

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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.…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The viewer will learn how to dynamically set the form action using jQuery.

738 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