Home > Backend Development > PHP Tutorial > ThinkPHP implements a method to quickly create models for non-standard name data tables, thinkphp model_PHP tutorial

ThinkPHP implements a method to quickly create models for non-standard name data tables, thinkphp model_PHP tutorial

WBOY
Release: 2016-07-13 10:12:47
Original
1296 people have browsed it

ThinkPHP implements a method to quickly create models for non-standard name data tables, thinkphp model

The example in this article describes how ThinkPHP implements non-standard name data tables to quickly create models. Share it with everyone for your reference. The specific method is as follows:

Non-standard name data table, for example: cow_archives_4, similar naming methods are common in Qibo cms, 08cms and other document model data table naming. It is assumed that the data table prefix has been configured in the configuration file:

Copy code The code is as follows:
return array(
//'Configuration item'=>'Configuration value'
//Database configuration
'DB_PREFIX'=>'cow_',
);
?>

New model,Archives4Model.class.php
Copy code The code is as follows:
class Archives4Model extends Model{
        protected $tableName = 'archives_4';                                          }
?>

D method instantiation:
Copy code The code is as follows:
$archives4=D("Archives4");
$rsdb=$archives4->select();
var_dump($rsdb);
I hope this article will be helpful to everyone’s ThinkPHP framework programming.

http://www.bkjia.com/PHPjc/919617.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/919617.htmlTechArticleThinkPHP’s method of quickly creating a model for non-standard name data tables, thinkphp model. This article describes the example of ThinkPHP’s implementation of non-standard names. A quick way to create models from data tables. Share with everyone...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template