圖片上傳||預(yù)覽

圖片上傳

表單


第一鐘ajax
第二種ajax


第一中ajax的控制器
第二種ajax的控制器

在控制器里還要引用一個model文件和yii的組件 use app\models\UploadForm;? use yii\web\UploadedFile;

圖片預(yù)覽


ajax預(yù)覽代碼

索引

1> 普通索引(index)(MUL代表普通索引)

? 特點:沒有任何限制,當(dāng)我們定義了普通索引之后,直接搜索數(shù)據(jù)即可使用它

? (1) 在創(chuàng)建表的時候,定義一個普通索引

????? create tabel test1(

??????? id int unsigned not null,

?????? name varchar(32) not null,

????? sex enum('m','w') not null default 'w',

????? age tinyint not null default 18,

???? index id(id) 索引類型 索引名(字段名)

? );

(2)在建表之后,給某個字段添加普通索引

?? create index id on test1(id);

?? create 索引類型 索引名 on 表名(字段名);

(3)刪除一個普通索引的方法

? drop index id on test1;

? drop 索引類型 索引名 on 表名;

2> 唯一索引(unique)(UNI代表唯一索引)

?特點:具有唯一索引的字段,它的值只能出現(xiàn)一次,出現(xiàn)重復(fù)的值則會報錯!

? 同時,一個表中可以有多個字段添加唯一索引

(1)在建表時創(chuàng)建唯一索引的方法一

???? create table test1(

????? id int unsigned not null,

???? name varchar(32) not null,

??? sex enum('w','m') not null default 'm',

??? age tinyint not null default 18,

??? unique index name(name) //索引類型 索引名(字段名)

?? );

(2)在建表時創(chuàng)建唯一索引的方法二

????? create table test1(

? ? ?? id int unsigned not null,

? ? ? name varchar(32) not null unique, //直接給字段添加唯一索引

? ? ? sex enum('w','m') not null default 'w',

? ?? age tinyint not null default 18

? );

(3) 在建表之后添加一個唯一索引

? create unique index id on test1(id);

? create 索引類型 索引名 on 表名(字段名);

(4)刪除一個表中的唯一索引的方法

drop index id on test1;

drop 索引類型 索引名 on 表名;

3> 主鍵索引(primary key)

?? 特點:它的唯一索引基本上使用方法以及特性一致,唯一的區(qū)別是,唯一索引在

一個表中可以多次定義、主鍵索引只能定義一次,而且主鍵索引一般會添加到id字段當(dāng)中

(1)建表時創(chuàng)建一個主鍵索引的方法

?? create table test1(

?? id int unsigned not null auto_increment primary key, //添加主鍵

?? name varchar(32) not null,

?? sex enum('w','m') not null default 'm',

?? age tinyint not null default 18

? );

(2)建表之后,添加一個主鍵索引的方法

1.alter table test1 change id id int unsigned not null auto_increment primary key;

alter table 表名? change 字段原名 字段新名 類型 約束條件……;

2.alter table test1 modify id int unsigned not null auto_increment priamry key;

?? alter table 表名? modify 字段名 類型 約束條件……;

(3) 刪除主鍵索引的方法

? 因為主鍵索引比較特殊,所以我們在刪除主鍵索引時,必須先來查看表結(jié)構(gòu),看表中

? 具有主鍵索引的那個字段,是否同時擁有 auto_increment 這個約束條件,如果有,

? 先刪除 auto_increment 這個約束條件,之后才能刪除主鍵索引

1.先查看表結(jié)構(gòu),查看是否擁有 auto_increment 關(guān)鍵字

? desc 表名;

2.如果有 auto_increment 關(guān)鍵字,則需要先刪除該關(guān)鍵字

? alter table test1 modify id int unsigned not null;

? alter table 表名 modify 字段名 字段類型 約束條件;

3.刪除主鍵索引

? alter table test1 drop primary key;

? alter table 表名 drop 主鍵索引;

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • MySQL5.6從零開始學(xué) 第一章 初始mysql 1.1數(shù)據(jù)庫基礎(chǔ) 數(shù)據(jù)庫是由一批數(shù)據(jù)構(gòu)成的有序的集合,這些數(shù)據(jù)...
    星期四晚八點閱讀 1,234評論 0 4
  • MySQL 數(shù)據(jù)庫常用命令 1、MySQL常用命令 create database name; 創(chuàng)建數(shù)據(jù)庫 use...
    55lover閱讀 5,041評論 1 57
  • 系統(tǒng)用戶: 1.sys system(sys權(quán)限最高) 2.sysman(操作企業(yè)管理器) 密碼是安裝的時候輸入的...
    3hours閱讀 1,709評論 0 0
  • 1.感恩羅老師今天的增員分享,對我一直懶惰和拖延有很大的震撼。 2.感恩二東邀請參加投資班學(xué)習(xí),接觸下高端人群的生...
    Hello滑先生閱讀 202評論 0 0
  • 很久以前,一個山東的手藝人,他很喜歡雕塑妖魔鬼怪的東西,也雕塑得活靈活現(xiàn),技藝傳出去后,很多人都找他雕塑,因此發(fā)了...
    老抓閱讀 1,004評論 7 12

友情鏈接更多精彩內(nèi)容