Yii 1x to yii 2x details change

Source: Internet
Author: User
Tags yii
Yii2The default format for returning table name values is {{%user}}
and Yii1is returned in the {{user}}
Look at the source code, found that in Yii1Of

path\to\yii\framework\db\schema\cdbschema.php line78

if($this->_connection->tablePrefix!==null && strpos($name,'{{')!==false)            $realName=preg_replace('/\{\{(.*?)\}\}/',$this->_connection->tablePrefix.'$1',$name);        else            $realName=$name;

and Yii2 the

path\to\vendor\yiisoft\yii2\db\connection.php line795

return preg_replace_callback(        '/(\\{\\{(%?[\w\-\. ]+%?)\\}\\}|\\[\\[([\w\-\. ]+)\\]\\])/',        function ($matches) {            if (isset($matches[3])) {                return $this->quoteColumnName($matches[3]);            } else {                return str_replace('%', $this->tablePrefix, $this->quoteTableName($matches[2]));            }        },        $sql    );

It will be found that not only the class of the call is changed, but even the method is changed, and the change of the str_place prg_replace regular expression can be observed at the same time instead of being fast outdated, so % what is the new one behind? I thought it was the suffix, read the source code and there is no other things, run it is just a simple replacement. This means that each addition is % replaced by a prefix. Maybe the author would like to add a suffix for the convenience of other people.

Take a look at the back of the regular \\[\\[([\w\-\. ]+)\\]\\]) , if the table name is said [[user]] , then the call is $this->quoteColumnName($matches[3]); returned `user` , the outer set of an anti-quotation mark, the generated SQL statement has been inverted quotation marks, so the table name is not used [[xxx]] for nesting.

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the Yii 1x to Yii 2x of the details of the changes, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

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