<?php
include_once("$config[webroot]/module/buy/includes/buy_class.php");

class buy_api extends buy
{
	function buy_api()
	{
		parent::buy();
	}
	
	/*
	function update_uid($array)
	{	
		$this->buy_merge_user($array);
	}
	*/
	
	function delete_by_uid($array)
	{
		$userid=$array['uid'];
		$company_id=$array['company_id'];
		
		if(!empty($userid))
		{
			$sql="select id from ".BUY." where userid='$array[uid]'";
			$this->db->query($sql);
			$res=$this->db->getRows();
			foreach($res as $v)
			{
				$this->db->query("delete from  ".BUY." where id='$v[id]'");
				$this->db->query("delete from  ".BUYPRO." where buy_id='$v[id]'");
				$this->db->query("delete from  ".BUYQPRO." where buy_id='$v[id]'");
			}
		}
		
		if(!empty($company_id))
		{
			$sql="select id from ".BUY." where company_id='$array[uid]'";
			$this->db->query($sql);
			$res=$this->db->getRows();
			foreach($res as $v)
			{
				$this->db->query("delete from  ".BUY." where id='$v[id]'");
				$this->db->query("delete from  ".BUYPRO." where buy_id='$v[id]'");
				$this->db->query("delete from  ".BUYQPRO." where buy_id='$v[id]'");
			}
		}
		
		return true;
	}
}
?>