yii?? ??????? ??? ??????
Yii2.0? ?????? ??? ?? ???? ??
Yii? PDO(PHP Date Object)? ???? ??? ??????? ????? Yii? ?? ?? ?? ??????? ?? ??? ??? ??? ? ????. ?? ??? ?????? ??? ? ???? ?? ?????? ???.
?? ??: yii ?????
???????? ??? ???? ?? ?? ?????? ???? ??? ???? ???. Yii ???????? ?????? ??? ???? ?? ?? ?? ?? ??? ????. ?? ???? ?? ?? ? ????.
'components' => [ 'db' => [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname=yii2advanced', 'username' => 'root', 'password' => '', 'charset' => 'utf8', ], // ... ... ], // ... ...
??? ??? ???? ????. Yii? ?????? ??? ?? ?? ?? yiidbConnection? ?????. ? ??? PDO? ??? ???? ????, ??? ?????? ?? ???? ???, ?? ?? ?????? ?????. ??? ???? ????? ???? ?? ???? ?????? ??? ??? ???? ?? ??? ? ??? ? ????. ?? ??, MySQL ??? Money ?? ??? ??? ? ?? ?? ?? ? ?? ??? ??? ????.
?????? ???
Connection? ??? ??????? ????? ???? ?????? ???? ???? ???. Yii? ??? ?? ?????? ???? ????, ??? ?????? ?? ???(DBMS)? ?? ?? ???? ??? ?? ????. ???? ??? ?? ???? ????.
yiidbSchema ?? ???? ??? DBMS? ???? ???? ? ?????.
yiidbTableSchema? ??? ??? ???? ? ?????.
yiidbColumnSchema? ?? ??? ???? ? ?????.
yiidbpgsql, yiidbmysql, yiidbsqlite, yiidbmssql, yiidboci, yiidbcubird? ??? ???? ??? DBMS? ????? ???? ? ?????.
yiidbConnection?? PDO ?????? ????? ?? ??? ??? ?? ?? ??? ???? ? ???? $schemaMap ??? ????.
public $schemaMap = [ 'pgsql' => 'yii\db\pgsql\Schema', // PostgreSQL 'mysqli' => 'yii\db\mysql\Schema', // MySQL 'mysql' => 'yii\db\mysql\Schema', // MySQL 'sqlite' => 'yii\db\sqlite\Schema', // sqlite 3 'sqlite2' => 'yii\db\sqlite\Schema', // sqlite 2 'sqlsrv' => 'yii\db\mssql\Schema', // newer MSSQL driver on MS Windows hosts 'oci' => 'yii\db\oci\Schema', // Oracle driver 'mssql' => 'yii\db\mssql\Schema', // older MSSQL driver on MS Windows hosts 'dblib' => 'yii\db\mssql\Schema', // dblib drivers on GNU/Linux (and maybe other OSes) hosts 'cubrid' => 'yii\db\cubrid\Schema', // CUBRID ];
Yii? ? ???? 10?? DBMS(6? ???)? ????? ??? ? ????. default ), ???? ?? ?? ?????. ? ??? ??? DBMS? ???? ???? Yii? ???? ????? DBMS? ??? ? ??? Schema? ?? ??? ??? ???.
Schema ?? ???
yiidbSchema? ?? ?????, ???? ??? ??? DBMS? ?? 6?? ?? ??? Schema? ?? ????. ??? ?? ???? ?? ?? ???? ?????. ?? ? yiidbSchema? ???????.
abstract class Schema extends Object { // 預(yù)定義16種基本字段類型,這16種類型是與DBMS無關(guān)的,具體到特定的DBMS時,Yii會自動 // 轉(zhuǎn)換成合適的數(shù)據(jù)庫字段類型。 const TYPE_PK = 'pk'; const TYPE_BIGPK = 'bigpk'; const TYPE_STRING = 'string'; const TYPE_TEXT = 'text'; const TYPE_SMALLINT = 'smallint'; const TYPE_INTEGER = 'integer'; const TYPE_BIGINT = 'bigint'; const TYPE_FLOAT = 'float'; const TYPE_DECIMAL = 'decimal'; const TYPE_DATETIME = 'datetime'; const TYPE_TIMESTAMP = 'timestamp'; const TYPE_TIME = 'time'; const TYPE_DATE = 'date'; const TYPE_BINARY = 'binary'; const TYPE_BOOLEAN = 'boolean'; const TYPE_MONEY = 'money'; // 加載表schema,需要子類具體實現(xiàn) abstract protected function loadTableSchema($name); // ... ... }
yiidbSchema ???? ?? ?? ??? ??? ?????. DBMS ?? ?? ??? ???? 16?? ?? ?? ??? ?????. ? 16?? ??? DBMS? ??? ??? ????. ?? DBMS? ?? Yii? ?? ??? ?????? ?? ???? ?? ?????. ???????? ?? ??? ???? ?? ?? ?? 16?? ??? ?????. ? ??, ???? ?? DBMS? ?? ????? ??? ??? ??? ????.
16?? ??? ??? ?? ??? ????? ? ? ???? ??? ??? ??? ?????.
yiidbSchema::loadTableSchema()? ?? ?? ????? ?? ??? ???, ?? DBMS? ?? ????? ???? ?? ???? ???? ???? ??? ?????. ???? yiidbmysqlSchema ?? ???? ?? ?? ?????.
class Schema extends \yii\db\Schema { // 定義一個數(shù)據(jù)類型的映射關(guān)系 public $typeMap = [ 'tinyint' => self::TYPE_SMALLINT, 'bit' => self::TYPE_INTEGER, 'smallint' => self::TYPE_SMALLINT, 'mediumint' => self::TYPE_INTEGER, 'int' => self::TYPE_INTEGER, 'integer' => self::TYPE_INTEGER, 'bigint' => self::TYPE_BIGINT, 'float' => self::TYPE_FLOAT, 'double' => self::TYPE_FLOAT, 'real' => self::TYPE_FLOAT, 'decimal' => self::TYPE_DECIMAL, 'numeric' => self::TYPE_DECIMAL, 'tinytext' => self::TYPE_TEXT, 'mediumtext' => self::TYPE_TEXT, 'longtext' => self::TYPE_TEXT, 'longblob' => self::TYPE_BINARY, 'blob' => self::TYPE_BINARY, 'text' => self::TYPE_TEXT, 'varchar' => self::TYPE_STRING, 'string' => self::TYPE_STRING, 'char' => self::TYPE_STRING, 'datetime' => self::TYPE_DATETIME, 'year' => self::TYPE_DATE, 'date' => self::TYPE_DATE, 'time' => self::TYPE_TIME, 'timestamp' => self::TYPE_TIMESTAMP, 'enum' => self::TYPE_STRING, ]; }
yiidbmysqlSchema? ?? ?? ??? ?????. ? ?? ??? ?? ??? MySQL ??????? ?? ??? 16?? ?? ??? ?? ?? ?? ?????. ?, MySQL Schema? ???? MySQL? ?? ??? ???? ??? 16?? ?? ??? ???? ?????.
??? ??(??? ???)
yiidbTableSchema ???? ??? ???? ??? ???? ? ?????.
class TableSchema extends Object { public $schemaName; // 所屬的Schema public $name; // 表名,不包含Schema部分 public $fullName; // 表的完整名稱,可能包含一個Schema前綴。 public $primaryKey = []; // 主鍵 public $sequenceName; // 主鍵若使用sequence,該屬性表示序列名 public $foreignKeys = []; // 外鍵 public $columns = []; // 字段 // ... ... }
? ???? yiidbTableSchema? ??? ?????. ?? ??? ???? ?? ??? ?? ??? ????? ????? ??? ? ????. ??? ?? ???? ??? ???.
? ???
yiidbColumnSchema ???? ?? ??? ???? ? ?????. ???????.
class ColumnSchema extends Object { public $name; // 字段名 public $allowNull; // 是否可以為NULL /** * @var string abstract type of this column. Possible abstract types include: * string, text, boolean, smallint, integer, bigint, float, decimal, datetime, * timestamp, time, date, binary, and money. */ public $type; // 字段的類型 /** * @var string the PHP type of this column. Possible PHP types include: * `string`, `boolean`, `integer`, `double`. */ public $phpType; // 字段類型對應(yīng)的PHP數(shù)據(jù)類型 /** * @var string the DB type of this column. Possible DB types vary according to the type of DBMS. */ public $dbType; public $defaultValue; // 字段默認(rèn)值 public $enumValues; // 若字段為枚舉類型,該屬性用于表示可供枚舉的值 /** * @var integer display size of the column. */ public $size; public $precision; // 若字段為數(shù)值,該屬性用于表示精度 /** * @var integer scale of the column data, if it is numeric. */ public $scale; /** * @var boolean whether this column is a primary key */ public $isPrimaryKey; // 是否是主鍵 public $autoIncrement = false; // 是否是自增長字段 /** * @var boolean whether this column is unsigned. This is only meaningful * when [[type]] is `smallint`, `integer` or `bigint`. */ public $unsigned; // 是否是unsigned,僅對支持的類型有效 public $comment; // 字段描述信息 /** * Converts the input value according to [[phpType]] after retrieval from the database. * If the value is null or an [[Expression]], it will not be converted. * @param mixed $value input value * @return mixed converted value */ public function phpTypecast($value) { if ($value === '' && $this->type !== Schema::TYPE_TEXT && $this->type !== Schema::TYPE_STRING && $this->type !== Schema::TYPE_BINARY) { return null; } if ($value === null || gettype($value) === $this->phpType || $value instanceof Expression) { return $value; } switch ($this->phpType) { case 'resource': case 'string': return is_resource($value) ? $value : (string) $value; case 'integer': return (int) $value; case 'boolean': return (bool) $value; case 'double': return (double) $value; } return $value; } /** * Converts the input value according to [[type]] and [[dbType]] for use in a db query. * If the value is null or an [[Expression]], it will not be converted. * @param mixed $value input value * @return mixed converted value. This may also be an array containing the value as the first element * and the PDO type as the second element. */ public function dbTypecast($value) { // the default implementation does the same as casting for PHP but it should be possible // to override this with annotation of explicit PDO type. return $this->phpTypecast($value); } }
? ??? yii?? ??????? ???? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

?? ??? ???? ????, ????, ???? ??? ?? ??? ?? ??? ??? ?????. ??? ??? ??? ??? ??? ?? ???? ??? ?? ??? ??? ?? ??? ?? ??. ??? ?? ??? ??? ?? ??, ?? ? TV ?? ??, ????? ??? ? ?? ???? ?? ?????. ????? ??? ????? ??? ?????? ???? ?? ?? ??? ?????. ?? ?? ??? PHP? Yii2, Ph? ?? ??? PHP ????? ? ?? ???? ?????.

Yii ?????? ? ?????? ?? ????? ????? ?? ??? ??? ?? ??? ???? ?? ?? PHP ? ?????? ????????. ??? ??? ??? ?? ?? ? ?????. Yii ???????? SQL? ??? ??? ???? ??????? ????? ???? ????? ???? ??? ? ????. Yii ?????? ?? ???? ?? ActiveRecord ??, QueryBuilder ??, ?? ?? ? ?? SQL ?? ??? ?????.

? ??????? ?? ??? ?? ???? ?? ???? ?? ?????? ??? ? ?? ? ?? ???? ?? ?????. Symfony? Yii2? ? ?? ?? ?? PHP ????????. ? ? ??? ??? ??? ??? ??? ??? ? ??????? ???? ?? ?? ?? ?????? ? ?????? ???? ? ?? ??? ?? ? ??? Symphony? Yii2? ?? ??? ???????. ?? ?? Symphony? PHP? ??? ?? ?? ? ?????? ??????? ??? ???? ???.

???? ??? ??? ????? ????? ??? ??? ?? ??? ??? ?? ? ?? ?????. ??? ???? ???? ?? ???? ?? ???? ???? ?? ?? ?????. PHP ????? Yii? ???? ??? ? ??????? ??? ???? ? ??? ?? ??? ????????. ??? Yii ?????? ???? ???? ???? ?? ???? ???? ??? ?????. ?????? ?? ?? Yii ??????? ?????? ??? ?? ??? ?????. ??? ?? ????? ?? ???? ??? ???? ???

Laravel? YII? ?? ???? ?? ??, ??? ?? ? ?? ???????. 1. Laravel? ??? ???? ???? ????? Eloquentorm ? Artisan ??? ?? ??? ??? ???? ?? ?? ? ????? ?????. 2.YII? ??? ???? ????, ? ?? ??????? ????, ???? Activerecord ? ?? ???? ????? ??? ?? ??? ????.

Docker? ???? YII ??????? ??????? ???? ???? ??? ?????. 1. Dockerfile? ???? ??? ?? ????? ?????. 2. DockerCompose? ???? YII ?? ???? ? MySQL ??????? ??????. 3. ??? ?? ? ??? ???????. ???? ?? ?? ???? ??? ????? ??? ??? ??? ???? ?? Dockerfile? ?? ??? ?? ??? ???? ?? ?????.

???? ??? ???? ?? API? ??? ?????? ?? ???? ???? ??? ??? ?????. ??? ?? ??? ?? ????? ???? API ?????? ???? ?? ?? ? ????? ????. API ?????? ??? ? Yii2? Symfony? ???? ???? ?? ?? ? ?? ?????. ???? API ???? ?? ?? ? ?????? ? ????? ? ? ?????? ???? ? ?? ??? ?????. 1. ?? ?? Yii2? Symfony? ??? ??? ? ?? ?? ?? ??? ?? ??? PHP ????????.

"Yii? ??????"?? ???? Yii? ??? ???? 2014? 10?? ??? Yii 2.0? ??? ??? ???? ???? ?? ????? Yii ????? ??? ?????. ?> ?? Yii2 ????? ?????? Yii2PHP ?????? ???? ??? ????? ???????. ?? ??????? Yii? ?? ??? ???? ?? ??? ???? ??? ???????. ???? cron ???? ? ??? ?? URL? wget? ???? ????? ??? ??????. ?? ?? ?? ??? ???? ?? ?? ??? ?????. Security for Startup ????? ??? ???? ? ?? ??? ???? ?? ?? ?? ???? ???? ?????.
