<? phpclass BaseLogic extends MyDB { protected $tabName; protected $fieldList; protected $messList; function add($postList) { $fieldList=''; $value=''; foreach ($postList as $k=>$v) { if(in_array($k, $this->fieldList)){ $fieldList.=$k.","; if (!get_magic_quotes_gpc()) $value .= "'".addslashes($v)."',"; else $value .= "'".$v."',"; } } $fieldList=rtrim($fieldList, ","); $value=rtrim($value, ","); $sql = "INSERT INTO {$this->tabName} (".$fieldList.") VALUES(".$value.")"; echo $sql; $result=$this->mysqli->query($sql); if($result && $this->mysqli->affected_rows >0 ) return $this->mysqli->insert_id; else return false; }
This is a PHP class for data processing. Friends who need it can download it and use it.
The name of the table and the set of fields, which have the following functions:
Function: add($postList)
Function: Add
Parameters: $postList Submitted variables List
Returns: The newly inserted auto-increment ID
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
12Jul2016
URL, form data, IP and other processing classes, url form. URL, form data, IP and other processing classes, url form? php class ev{ public $cookie; public $post; public $ get; public $file; public $url; public $G; private $e; public function __con
06Jul2016
The implementation method of PHP processing binary data, php processing binary data. Implementation method of PHP processing binary data, PHP processing binary data PHP needs to use pack() and unpack() to process binary data. pack() is used to convert data into binary data. The usage method is as follows:
06Jul2016
During development, it is often necessary to process the list data taken out from the database. There are three ways to write them, all of which can get the same result. I have always been accustomed to using the first way. Which one is better in terms of readability and performance? List data such as: {code...} Writing method 1, modify the original array...
13Dec2024
Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...
12Jul2016
PHP mathematical operations and data processing example analysis, data processing example analysis. PHP mathematical operations and data processing example analysis, data processing example analysis This article describes PHP mathematical operations and data processing methods with examples. Share it with everyone for your reference, the details are as follows: 1.
12Jul2016
The implementation method of PHP processing binary data, php processing binary data. Implementation method of PHP processing binary data, PHP processing binary data PHP needs to use pack() and unpack() to process binary data. pack() is used to convert data into binary data. The usage method is as follows:
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images