In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you the "CI framework common function encapsulation", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn the "CI framework common function encapsulation" this article.
The details are as follows:
/ * encapsulate query function * / 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 } / * encapsulate a single query function * / public function get_row ($table='',$where=array (), $fields ='*') {if ('= = $table) {return false;} / / query and return related results $query = $this- > db- > select ($fields)-> where ($where)-> get ($table); $res = $query- > row_array (); return $res } / * encapsulate the update function * / public function update_what ($table='', $where=array (), $data = array ()) {if ('= = $table | | true = empty ($where) | | true = empty ($data)) {return false;} / / Update the corresponding fields $query = $this- > db- > update ($table,$data,$where); return $query;} / * * self-increment and subtraction of the extended database function * using:* $table=' codeuser' $where=array ('id'= > 1); $data=array (' usestate'= > 'usestate+1','imgtype' = >' imgtype-1'); * / public function update_count ($table ='', $where=array (), $data=array ()) {/ / return false if ('= = $table | | empty ($data)) {return false if the table name is empty or the data is empty } foreach ($data as $key = > $val) {if (false! = = stripos ($val,'+') | | false! = = stripos ($val,'-')) {$this- > db- > set ($key, $val, FALSE);} else {$this- > db- > set ($key, $val);}} $res = $this- > db- > where ($where)-> update ($table); return $res } / * encapsulate the insert function * / public function insert_what ($table ='', $data = array ()) {if ('= = $table | | true = empty ($data)) {return false;} / / insert related records $query = $this- > db- > insert ($table, $data); return $query } / * Delete record encapsulation function * / 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 related 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 the controller:\ r\ n "; $error. = $func." The debugging information of the method is as follows:\ r\ n "; $error. = $org_error;file_put_contents (". / error_log.txt ", $error."\ r\ n ", FILE_APPEND);}} these are all the contents of the article" CI Framework Common function Encapsulation ". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.