<?php
/**
  * @method 宜配车型库主库表基本操作
  * @author soul
  * @copyright 2016/3/31
  */
class EpcBase
{
	protected $EPCDb = null;
	protected $EtkId = null;
	protected $EPCIMGALL = false;
	public function __construct($etkIdy)
	{	
		$this->EtkId = $etkIdy;
		$this->EPCDb = new LibDb (mvc::$cfg['DB']['EPC'][$etkIdy]);
		$this->EPCIMGALL = mvc::$cfg['BYUID'] && in_array(mvc::$cfg['BYUID'], mvc::$cfg['EPCIMGALL_UID'])? true: false;
	}
	
	/**
	  * @method 查询表信息
	  * @param  $table 表明 如：yp_product 或者 yp_product as a join yp_number as b on a.pid=b.pid
	  * @param  $fieldArr 需要查询的字段名称数组
	  * @param  $where 查询条件
	  * @param  $oneRow true|false
	  * @author soul
	  * @copyright 2016/3/30
	  * @return 
			成功 ["status"=>true, "data"=> $oneRow=false 二维数组 ; $oneRow=true 一维数组] 
			失败 ["status"=>false, "data"=> 错误信息]  
	  */
	public function get($table, $fieldArr, $where = '', $oneRow = false)
	{
		if(!empty($table) && is_array($fieldArr))
		{
			$sql = sprintf("select %s from %s where 1=1 %s", implode(',', $fieldArr), $table, $where);
			$res = $oneRow? $this->EPCDb->Row($sql): $this->EPCDb->Table($sql);
			if($res !== false)
			{
				return LibFc::ReturnData(true, $res);
			}
			else
			{
				return LibFc::ReturnData(false, 'SQL:'.$sql.'执行失败。');
			}
		}
		return LibFc::ReturnData(false, $table.'查询提供的参数不正确。');
	}
}