Yii2
The default format for returning table name values is
{{%user}}
and
Yii1
is returned in the
{{user}}
Look at the source code, found that in
Yii1
Of
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.