<?php
include(dirname(__file__)."/../includes.php");

//分享基础api函数
function share_read_base($fields="*",$condition="",$by_col="",$order="",$num="",$cache="",$cache_key=""){
	global $tablePreStr;
	$t_mood=$tablePreStr."mood";
	$plugin_rs=array();
	$dbo=new dbex;
  dbplugin('r');
  if($num==''||$num >= 1000){
  	$limit=" limit 1000 ";
  }else{
  	$limit=" limit $num ";
  }
  if($by_col!=''){
  	$by_col=" order by $by_col ";
  }
  $sql=" select $fields from $t_mood where $condition $by_col $order $limit ";
  if($cache==1&&in_array($num,array(10,20,50))&&$cache_key!=''){
		$key=$cache_key.$order.'_'.$num;
		$key_mt=$cache_key.'mt_'.$order.'_'.$num;
		$plugin_rs=model_cache($key,$key_mt,$dbo,$sql);
	}
	if(empty($plugin_rs)){
		$plugin_rs=$dbo->getRs($sql);
	}
	return $plugin_rs;
}

function mood_self_by_mid($fields="*",$id){
	$fields=filt_fields($fields);
	$id_str=filt_num_array($id);
	$condition=" mood_id in ($id_str) ";
	return share_read_base($fields,$condition);
}

?>