What is the effect of moving the _initialize in the "thinkphp" Model base class Contruct method to the end?

Source: Internet
Author: User
Version: thinkphp 3.1.3
Question: If _initialize () is defined in the thinkphp in the custom model, the data cannot be queried in this _initialize using $this.
My idea: What is the effect of moving _initialize from the __contruct method in the model base class to the very end of the method? For analysis!

File/thinkphp/lib/core/model.class.php,model in base class __contruct $this->_initialize moved to the $this->db ... What will be the impact?
    /** * Schema function * Get instance object field check for DB class * @access public * @param string $name model name * @param string $tablePre Fix table prefix * @param mixed $connection Database connection information */Public function __construct ($name = ", $tablePrefix =", $connection =        ") {//model initialization $this->_initialize (); Gets the model name if (!empty ($name)) {if (Strpos ($name, '. '))            {//Support database name. Definition of model Name list ($this->dbname, $this->name) = Explode ('. ', $name);            }else{$this->name = $name;        }}elseif (Empty ($this->name)) {$this->name = $this->getmodelname ();        }//Set table prefix if (is_null ($tablePrefix)) {//prefix null means no prefix $this->tableprefix = ';        }elseif ('! = $tablePrefix) {$this->tableprefix = $tablePrefix;        }else{$this->tableprefix = $this->tableprefix? $this->tableprefix:c (' Db_prefix ');    }//Database initialization operation//Get Database Operations Object    The current model has separate database connection information $this->db (0,empty ($this->connection)? $connection: $this->connection);        What effect would it have if we moved _initialize here?    $this->_initialize (); }


Reply to discussion (solution)

The effect is that the framework runs out of error.

The effect is that the framework runs out of error.



Why is this,

Initialize's intention was to initialize
_initialize has no parameters or returns, and obviously cannot interfere with the execution of the scheduled process.
So it doesn't matter where you put it.

Really did not do any operation, it is estimated to be used for debugging purposes.

  • Related Article

    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.