_table = 'common_member_stat_field'; $this->_pk = 'optionid'; parent::__construct(); } public function count_by_fieldid($fieldid) { return $fieldid ? DB::result_first('SELECT COUNT(*) FROM %t WHERE fieldid=%s', array($this->_table, $fieldid)) : 0; } public function fetch_all_by_fieldid($fieldid, $start = 0, $limit = 0) { return DB::fetch_all('SELECT * FROM %t WHERE fieldid=%s'.DB::limit($start, $limit), array($this->_table, $fieldid)); } public function insert_batch($inserts) { $sql = array(); foreach($inserts as $value) { if($value['fieldid']) { $sql[] = "('$value[fieldid]', '".addslashes($value['fieldvalue'])."')"; } } if($sql) { DB::query('INSERT INTO '.DB::table($this->_table)."(fieldid, fieldvalue) VALUES ".implode(', ', $sql)); } } } ?>