CI Framework Learning VI (Common function encapsulation)

Source: Internet
Author: User

        /** * Package Query functions */public function get_what ($table = ", $where =array (), $fields = ' * ') {if (' = = $table) {return false ;} Query and return related results $query = $this->db->select ($fields)->where ($where)->get ($table); $res = $query->result_ Array (); return $res;} /** * Package Update functions */public function update_what ($table = ", $where =array (), $data = Array ()) {if (' = = $table | | true = = = Empty ( $where) | | true = = = Empty ($data)) {return false;} Update the corresponding field $query = $this->db->update ($table, $data, $where); return $query;}  /** * Encapsulation Insert Function */public functions insert_what ($table = ", $data = Array ()) {if (' = = $table | | true = = = Empty ($data)) {return false;} Insert Related record $query = $this->db->insert ($table, $data); return $query;} /** * Delete Record encapsulation functions */public function delete_what ($table = ", $where =array ()) {if (true = = = Empty ($where) | | "= = $table) {return false;}    Delete Related table records $query = $this->db->delete ($table, $where); return $query;} /** * Debug Correlation function */public function debug_what ($org _error = ") {$con = $this-≫router->fetch_class ();    $func = $this->router->fetch_method (); if ($org _error) {$error. = Date ("Y-m-d h:i:s", Time ()). " \ r \ n "; $error. = __file__."        \ r \ n "; $error. = $con. "Under controller: \ r \ n"; $error. = $func. "Method debug information is as follows: \ r \ n"; $error. = $org _error;file_put_contents ("./error_log.txt" , $error. " \ r \ n ", File_append);}}

CI Framework Learning VI (Common function encapsulation)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.