<?php
class loveapiControl extends skymvc{
	
	public function __construct(){
		parent::__construct();
	}
	
	public function product($option=array(),&$rscount=false){
		$this->loadModel(array("loves","user","product"));
		$data=$this->loves->select($option,$rscount);
		if($data){
			foreach($data as $k=>$v){
				$ids[]=$v['object_id'];
			}
			if(!empty($ids)){
				$pro=$this->product->select(array("where"=>" id in("._implode($ids).") AND status>0 AND status<99 "));
				return $pro;
			}
		}
		
	}
	
	public function productByuser($userid,$limit=10,$orderby="  id DESC"){
		$this->loadModel(array("loves","user","product"));
		$userid=intval($userid);
		$option=array(
			"where"=>"userid=$userid",
			"start"=>0,
			"limit"=>$limit,
			"order"=>$orderby
		);
		$data=$this->loves->select($option);
		if($data){
			foreach($data as $k=>$v){
				$ids[]=$v['object_id'];
			}
			if(!empty($ids)){
				$pro=$this->product->select(array("where"=>" id in("._implode($ids).") AND status>0 AND status<99 "));
				return $pro;
			}
		}
	}
	
}

?>