tp 5フレームワークmodel層増削除
2169 ワード
save($data);
if($result===false){
return false;
} else{
return $this->id;
}
}
/**
*
* @param array $where
* @param array $data
* @return id id
*/
public function updateByWhere($where,$data)
{
$result = $this->where($where)->update($data);
if($result===false){
return false;
} else{
return true;
}
}
/**
*
* @param array $where
* @return id id
*/
public function deleteByWhere($where)
{
return $this->where( $where )->delete();
}
/**
*
* @param array $where
* @return num
*/
public function countWhere($where){
return $this->where($where)->count();
}
/**
*
* @param array $where
* @param string $fileds
* @return array ,
*/
public function findByAttributes($where = array(),$fileds="*")
{
return $this->field($fileds)->where( $where )->find();
}
/**
*
* @param array $where
* @param string $fileds
* @return array ,
*/
public function findAllByWhere($where = array(),$fileds="*",$order="id desc")
{
return $this->field($fileds)->where( $where )->order($order)->select()->toArray();
}
/**
*
* @param array $where
* @param string $fileds
* @param string $offset
* @param string $num
* @param string $order
* @return array ,
*/
public function loadAllData($where,$offset=0,$num=1,$order="id desc"){
return $this->where($where)->order($order)->limit("$offset,$num")->select()->toArray();
}
}