Configuration of the thinkphp

Source: Internet
Author: User

thinkphp configuration: Under Conf directory


' Url_pathinfo_depr ' = '-',//Modify the delimiter of the URL, ' tmpl_l_delim ' = ' <{',//Modify left delimiter ' tmpl_r_delim ' = '}> ',//Modify right delimiter ' Db_type ' + ' mysql ', //Set Database type ' db_host ' = ' localhost ',//Set host ' db_name ' = ' thinkphp ',//Set database name ' Db_user ' = ' root ', //Set username ' db_pwd ' + ', //Set password ' db_port ' = ' 3306 ', //Set port number ' db_prefix ' = ' tp_ ', //Set table prefix ' db_dsn ' = ' mysql://root: @localhost: 3306/thinkphp ',//Configure database information with DSN, priority ' Show_page_trace ' =>true ,//Open the page trace, also open debug debug mode ' Tmpl_template_suffix ' + '. html ',//change template file suffix name ' tmpl_file_depr ' + ' _ ',//Modify template file directory hierarchy ' Tmpl_detect_theme ' =>true,//Auto Detect template theme ' theme_list ' + ' your,my ',//Support Template subject list ' tmpl_parse_string ' =>array ( //Add your own template variable rule ' __css__ ' =>__root__. ' /public/css ', ' __js__ ' =>__root__. ' /public/js ',),

Detailed content

First, thinkphp 3 curd Introduction  (understanding) Two, thinkphp 3 read data    (emphasis) on the data read read$m=new Model (' user '); $m =m (' user ');select$m-> Select ();//Get all data, return Find$m->find ($id) as an array;//Get a single data GetField (field name)//Get a specific field value $arr= $m->where (' id=2 ') GetField (' username '); thinkphp 3 Create Data    (emphasis) add create$m=new Model (' user ') to the data, $m =m (' user '), $m, field name = value $m-> Add (); The return value is the new ID number four, thinkphp 3 delete data    (emphasis) $m =m (' User '); $m->delete (2);               Delete data with ID 2 $m->where (' id=2 ')->delete (); Same as above, also delete the data return value with ID 2 is the number of rows affected five, thinkphp 3 update data    (emphasis) $m =m (' User '), $data [' id ']=1; $data [' username ']= ' ztz2 '; $m- >save ($data);             The return value is the number of rows affected

A, ordinary query way A, string $arr= $m->where ("Sex=0 and Username= ' Gege '")->find (); b, array $data[' sex ']=0; $data [' Username ']= ' Gege '; $arr = $m->where ($data)->find (); Note: This is by default the relationship between and, if you use an or relationship, you need to add an array value $data[' sex ']=0; $data [' Username ']= ' Gege '; $data [' _logic ']= ' or '; second, expression Query method $data[' id ']=array (' lt ', 6); $arr = $m->where ($data)->select (); EQ equals NEQ not equal to GT greater than egt greater than or equal to LT less than elt less than equals like fuzzy query $data[' username ']=array (' like ', '%ge '); $arr = $m->where ($data) Select (); notlike$data[' username ']=array (' notlike ', '%ge% '); There are no spaces in the middle of the notlike $arr = $m->where ($data)->select (); Note: If a field is to match multiple wildcard characters $data[' username ']=array (' like ', Array ('% ' Ge% ', '%2% ', '% Five '), ' and ');//If there is no third value, the default relationship is the or relationship $arr= $m->where ($data)->select (); between$data[' id ']=array (' between ', Array (5,7)), $arr = $m->where ($data)->select ();//select * from ' tp_user ' WHERE (' id ' between 5 and 7) $data [' ID ']=array (' Not between ', Array (5,7));//Note that there must be a space between not and between $arr= $m->where ( $data)->select (); in$data[' id ']=array (' in ', Array (4,6,7)); $arr = $m->where ($data)->select ();//select * from ' tp_user ' WHERE (' id ' in (4,6,7)) $data [' ID ']=array (' No in ', Array (4,6,7)); $arr = $m where ($data)->select ();//select * from ' tp_user ' WHERE (' id ' not in (4,6,7)) Three, interval query $data[' ID ']=array (Array (' GT ', 4), Array (' LT ', 10));//The default relationship is the relationship of and//select * from ' tp_user ' WHERE (' id ' > 4) and (' ID ' <) ') $data [' ID ']=array (arra Y (' GT ', 4), array (' LT ', ' x '), ' or ')//relationship is or relationship $data[' name ']=array (Array (' Like ', '%2% '), array (' like ', '% Five '), ' gege ', '  or '); Statistics query count//Get the number max//Get the maximum number min//Get the minimum number AVG//Get average sum//get sum of five, SQL direct query A, query main number processing the result set of the successful return data of the read data returned a Boolean False$m=m (); $result = $m->query ("select * from T_user where ID >50"); Var_dump ($result); b, execute A failure to return a successful write operation that affects the number of rows returned by a Boolean false$m=m (), $result = $m->execute ("INSERT into T_user (' username ') VALUES (' ztz3 ')"); Var_dump ($result);

One, commonly used coherent operation 1.where help us set the query condition 2.order to sort the results $arr= $m->order (' id desc ')->select (); $arr = $m->order (array (' id ' = > ' desc ', ' sex ' = ' asc ')->select (); 3.limit limit result limit (2,5) limit (' 2,5 ') limit ("//limit") (0,10) 4. field set query fields (' username as Name,id ') field (Array (' username ' = ' name ', ' id ') field (' ID ', true)// Get all fields except ID 5.table6.group7.having second, add alias  used to define an alias string for the current data table page for querying paging (internally converted to limit) string and number join* for join support for queries String and array union* are used to support strings, arrays, and objects distinct for queries, distinct support Boolean lock for Database lock mechanism Boolean cache is used for query caching to support multiple parameters (later described in detail in the cache section) re Lation is used to correlate queries (need association model extension support) string validate used for data auto-validation array auto for data auto-complete array filter for data filtering strings scope* used for naming range strings, array additions will be discussed later in detail

One, the use of templates (emphasis) A, the Rules template folder [tpl]/[Group folder/][template theme Folder/] and the module name of the same folder [index]/and the name of the method name of the file [Index].html (. TPL) replacement template file suffix name (Modify the configuration file) ' Tmpl_template_suffix ' + '. html ',//change template file suffix B, modify template file directory hierarchy ' Tmpl_file_depr ' = ' _ ',//Modify template file directory hierarchy c, template theme ' Default_ THEME ' + ' your ',///Set Default template theme need to create a new your folder under the TPL how do I dynamically modify a template theme as a template theme folder? 1, in the background to prepare a function, modify the default template item in the config.php file 2, pass the URL t= topic parameter can modify different template ' default_theme ' = ' your ',//Set the default template theme ' Tmpl_detect_ THEME ' =>true,//auto-detect template theme ' theme_list ' + ' your,my ',//Support Template topic List II, Output template content (emphasis) A, Display1.display no parameters $this-> Display (); 2. can take parameter $this->display (other template files under this module folder); $this->display (' index2 '); $this->display (template file under other folders); $this->display (' public:error ');///Note that only the public folder and the error.html within the TPL are required, there is no need to have the public module $this->display ( Other topics under the folder template file);//need to turn on theme support $this->display (' My:Index:index '); $this->display (a URL path); $this->display ('. /public/error.html '); $this->display ('./public/error.html ', ' utf-8 ', ' text/xml '); $this->show ($content); 3. The Fetch method obtains the contents of the template file and returns the $content= as a string $thisFetch (' Public:error '), 4.show method does not need template file, can directly output template content $content= $this->fetch (' public:error ');d UMP ($content); Content=str_replace (' H1 ', ' I ', $content), $this->show ($content), assignment in template (emphasis)//$this->assign (' name ', ' Zhao Tun positive '); This->name= ' Zhao Tun is 2 '; $this->display (); template replacement (emphasis) __PUBLIC__: The public directory that will be replaced with the current site is usually/public/__root__: replace the address of the current Web site (not including domain name) __app__: will replace the current project URL address (without domain name) __group__: will replace the current group URL address (without domain name) __url__: will replace the current module's URL address (without domain name) __action__ : will replace the current operation's URL address (without domain name) __self__: Change the template variable rule for the current page URL, modify the configuration item ' tmpl_parse_string ' =>array (//Add your own template variable rule ' __css__ ' = >__root__. ' /public/css ', ' __js__ ' =>__root__. ' /public/js ',),

Configuration of the thinkphp

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.