【发布时间】:2011-02-06 20:26:58
【问题描述】:
像下面这样的通用 get() 方法是个好主意吗
function universal_get( $select=NULL, $from=NULL, $where=NULL, $group=NULL, $having=NULL, $order=NULL, $limit=NULL )
{
// condition checks
if ( is_string( $select ) OR is_array ( $select )) { $this->db->select( $select ); }
if ( is_string( $from ) ) { $this->db->from( $from ); }
if ( is_array( $where ) ) { $this->db->where( $where ); }
if ( is_string( $group ) OR is_array( $group ) ) { $this->db->group_by( $group ); }
if ( is_array( $having ) ) { $this->db->having( $having ); }
if ( is_array( $order ) ) { $this->db->order_by( $order ); }
if ( is_string( $limit ) OR is_int( $limit ) ) { $this->db->limit( $limit ); }
$result = $this->db->get( $from );
if ( $result->num_rows() > 0 ) { return $result->result(); }
else { return FALSE; }
}
或者像 PHP-ActiveRecord 这样的 ORM 会是更好的选择吗?
谢谢
【问题讨论】:
标签: orm codeigniter activerecord