Home > php教程 > php手册 > body text

ThinkPHP实现非标准名称数据表快速创建模型的方法,thinkphp模型

WBOY
Release: 2016-06-13 09:19:54
Original
1248 people have browsed it

ThinkPHP实现非标准名称数据表快速创建模型的方法,thinkphp模型

本文实例讲述了ThinkPHP实现非标准名称数据表快速创建模型的方法。分享给大家供大家参考。具体方法如下:

非标准名称数据表,例如:cow_archives_4,类似命名方法常见于齐博cms,08cms等文档模型数据表命名,假设已在配置文件中配置数据表前缀:

复制代码 代码如下:

return array( 
 //'配置项'=>'配置值' 
 //数据库配置 
 'DB_PREFIX'=>'cow_', 
); 
?>


新建模型,Archives4Model.class.php

复制代码 代码如下:

class Archives4Model extends Model{ 
     protected $tableName = 'archives_4'; 

?>


D方法实例化:

复制代码 代码如下:

$archives4=D("Archives4"); 
$rsdb=$archives4->select(); 
var_dump($rsdb);

希望本文所述对大家的ThinkPHP框架程序设计有所帮助。

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!