Yii Framework Forum: Problem With A Loop... - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problem With A Loop... Rate Topic: -----

#1 User is offline   AustinGeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 173
  • Joined: 22-September 12

Posted 05 February 2013 - 12:11 AM

In my controller, I have the following function...it should run thru numerous loops, but for some reason
returns after just the initial 100. I almost think it is not setting the start_element on subsequent loops.



protected function processJson($url, $auth, $params ) 
	{

			$rec = 0;	
			$start_element = 0;
			$num_elements = 100;			
			
			$params = array(""); //array("start_element"=>$start_element); 	
			$obj  = $this->getJson($url, $auth, $params);
			$count = $obj->response->count;  // total count of items
			if ($count < $num_elements)	
				$num_elements = $count;
			
			if ($count > 0 )
				$arraydata = array();
			
  			if ($rec < $count ) {  
			 if ($count-$rec < $num_elements ) 
				$num_elements = $count-$rec;

			 for ($i=0 ; $i<$num_elements; $i++) {
		 	  $arraydata[$i+$rec] = array(
			  "id" => $obj->response->publishers[$i]->id,
		 	  "name" => $obj->response->publishers[$i]->name
			  );
 		 	 
			 } //inner loop
			 $rec = $rec + $num_elements ;
			 $start_element = $start_element + $num_elements;
			 $params = array("start_element"=>$start_element); 			
			 $obj = $this->getJson($url, $auth, $params);
			 
			}// outer loop
		return $arraydata;

	}


0

#2 User is offline   AustinGeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 173
  • Joined: 22-September 12

Posted 05 February 2013 - 05:51 PM

I'm an idiot....

if ....doesn't qualify as a loop.

I'm a tired idiot...
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users