Thinkphp a method of implementing a non-standard name data table to create a model quickly _php

Source: Internet
Author: User
This paper describes the method of thinkphp to create a model for non-standard name data tables quickly. Share to everyone for your reference. Here's how:

Non-standard name data tables, such as: Cow_archives_4, naming methods common Uzibo cms,08cms such as document model data tables, assume that a data table prefix has been configured in the configuration file:

The code is as follows:

<?php
Return Array (
' Config item ' = ' config value '
Database configuration
' Db_prefix ' = ' cow_ ',
);
?>


New Model , Archives4Model.class.php

The code is as follows:

<?php
Class Archives4model extends model{
protected $tableName = ' archives_4 ';
}
?>


D Method Instantiation:

The code is as follows:

$archives 4=d ("Archives4");
$rsdb = $archives 4->select ();
Var_dump ($RSDB);

It is hoped that this article will be helpful to everyone's thinkphp framework design.

  • 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.