proxy_active = self::find('status = 1')->toArray(); if( $this->proxy_active ){ $count = count($this->proxy_active); if(!$this->next_proxy){ $this->next_proxy = 0; print('use proxy '.$this->proxy_active[$this->next_proxy++]['proxy']); return $this->proxy_active[$this->next_proxy++]['proxy']; }else { if($this->next_proxy >= $count-1){ $this->next_proxy = 0; print('use proxy '.$this->proxy_active[$this->next_proxy++]['proxy']); return $this->proxy_active[$this->next_proxy]['proxy']; } else { print('use proxy '.$this->proxy_active[$this->next_proxy++]['proxy']); return $this->proxy_active[$this->next_proxy++]['proxy']; } } } else { die('you don\'t have proxy'); } } public function deleteProxy(){ $activ_proxy = $this->next_proxy? $this->next_proxy - 1: $this->next_proxy; print('delete proxy '.$this->proxy_active[$activ_proxy]['proxy']); $non_active_proxy = self::findFirst('id = '.$this->proxy_active[$activ_proxy]['id']); $non_active_proxy->status = 0; $non_active_proxy->save(); } public function initialize() { } }