首页
开发手册
应用中心
工具
用户中心
FoundPHP Database Application
English
中文简体
English
上一篇
下一篇
### FoundPHP Database Application The database application is standardized, and we need to find a better solution under the premise of ensuring efficiency. We use array development to develop the database. The operation of the database adopts the array structure, and the framework will combine the data to generate the database statement corresponding to the platform. Considering that the operations of database writing and updating are unified, we have carried out array encapsulation on data insertion and updating to make the data more compatible with more databases. #### 1. Basic Data plugin/model/default.php ``` $table['a'] = 'articles'; //database table $t_index = 'aid'; //index id $t_field = '*'; //field $t_where = ""; //inquire $t_order = 'aid DESC'; //order ``` Statement Result: ``` SELECT * FROM articles ORDER BY aid DESC ``` #### 2. Associated Query plugin/model/default.php ``` $table['a'] = 'articles'; //database table a $table['b'] = 'article_data'; //database table b //The aid field of database table b is associated with the aid field of database table a. $ljoin['b'] = 'b.aid=a.aid'; $t_index = 'aid'; //index id $t_field = 'a.*,b.*'; //field $t_where = "a.lang='zh'"; //query conditions $t_order = 'a.aid DESC'; //order ``` Statement Result: ``` SELECT a.*,b.* FROM articles a LEFT JOIN article_data b ON b.aid=a.aid WHERE a.lang='zh' ORDER BY a.aid DESC ``` #### 3. Pagination FoundPHP integrated pagination method, only need to call pages (data set), turn it into a variable and call it in the template. plugin/model/default.php ``` //search $t_where = search_where($t_where,30); //order $t_order = search_order($t_order); //datasheets $sql = sql_select( array('sql'=>sql_join(),'where'=>$t_where['text'],'order'=>$t_order, 'type' => 'sql') ); $data_info = limit($sql,$config['set']['limit']); //paging function $pages = pages($data_info['info']); ``` plugin/view/default/default.htm ``` 分页:{pages} ``` #### 4. Submit data verification method | Subscript | if necessary | description | usage | | -------| -------| ------ | ------ | | lang | yes |Error message content | lang('Error message content [Search display content]') | | ope | yes |data processing method | PHP character processing methods such as trim, intval, floatvavl, strtotime, etc.法| | code | no |encryption processing | md5 base64 encryption, often used for password encryption| | long | no |character limit length | 5, 10 means that the character length is between 5 and 10 digits| | check | no |character judgment | Judge the characters after ope processing, see the Check usage table for specific usage| | t | yes |Output in the corresponding function|To output in the added function, do not output in the editing:'t'=>'add'| | req | no |must fill in the corresponding function | To be required in the add function, it is not necessary to fill in the editing:'req'=>'add'| | query | no |Check whether the data in this field exists, like fuzzy search| to be tested:'query'=>'1'| | search | no |automatically create a search box | search :'search'=>'1'| ``` $insert[$table['a']] = array( 'titles' => array( //Submit content //prompt language, [prompt item] prompt content when an error occurs 'lang' => lang('Sorry, [article title] is not entered or the format is wrong'), //trim to empty, boolval boolean value, intval integer value, floatval floating point value 'ope' => 'trim', //Blocking conditions! = No, ==, mail mailbox detection Do not enter spaces, mobile phone number detection 'check' => "==''", //required items correspond to the operation comma separation between todo 'req' => "add,edit", //corresponding to todo output data, operations between todos are separated by commas 't' => "add,edit", //whether to detect whether it exists in the database, if the value is changed to like, then fuzzy query 'query' => 1, //data list search item 'search' => 'like', ), ); ```