日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

php連接mysql+項目(1)

 知識書館 2022-07-17 發(fā)布于廣東

昨日回顧

         關(guān)系模型:二維表模型

         關(guān)系:數(shù)據(jù)表

         元組:數(shù)據(jù)表中的一條記錄record

         屬性:數(shù)據(jù)表中的字段field column

         關(guān)鍵字:一組用來唯標(biāo)簽一個元素的一屬性,關(guān)鍵字由一列或多列組成

         DBMS數(shù)據(jù)庫管理系統(tǒng)

         數(shù)據(jù)庫     è   數(shù)據(jù)表 è       記錄         è    字段

         登陸

         mysql –hlocahost –uroot –p

         enter your password>root

         查看數(shù)據(jù)庫

         show databases

         查看數(shù)據(jù)表

         show tables

         創(chuàng)建數(shù)據(jù)庫

         create databse 數(shù)據(jù)名 charset utf8;

         創(chuàng)建數(shù)據(jù)表

         create table 表名(字段名 字段類型 【附屬屬性】, 字段名 字段類型 【附屬屬性】) charset utf8;

         查看數(shù)據(jù)庫創(chuàng)建語句

         show create database 數(shù)據(jù)庫名;

         查看數(shù)據(jù)表創(chuàng)建語句

         show create table 表名;

         insert into 表名(字段列表) values(字段列表對應(yīng)的值的列表);

                   要求:所有的字段值都使用””’’括起來

         insert into 表名 values(字段值的列表);

                   id primary key

                   insert into tableName values(“asdfasdf”,);

         字段類型

         整型         tinyint    smallint    mediumint        int    bigint

         浮點         double      float

         字符型     char()                 varchar()

         文本型              text

         日期時間型

                   date

                   time

                   datetime

                   now()

【附屬屬性】

         primary key

         auto_increment

         not null

         default

查詢

         語法:

         select字段列表 from 表名 where子句】【order by子句】【limit子句】

         where子句的運算符

         >、<、=<=、>=、!=、like(%)in、between and、or、is null、is not null

         order by

         asc升序(默認排序方式)

         desc降序

         limit子句

         limit offset,rows

         更新

         語法:

         update表名 set 字段1=”1”, 字段2=”2”, 字段3=”3”

         刪除

         delete from 表名 where子句】;

刪除一個數(shù)據(jù)庫

drop database 數(shù)據(jù)庫名;

刪除一個表

drop table 表名;


php連接mysql

         1、php登陸數(shù)據(jù)庫

                  mysql_connect(“主機名:端口號”,”用戶名”,”密碼”);

                   如果數(shù)據(jù)連接成功mysql_connect()函數(shù)會返回,資源類型,如果不成功返回false;

         2、設(shè)置字符集

                   使用mysql_query()函數(shù)設(shè)置字符集

                   mysql_query(“set names utf8”);

         3、選擇數(shù)據(jù)庫

                   方法一:

                   mysql_query(“use數(shù)據(jù)庫名”);

                   方法二:

                   mysql_select_db(“數(shù)據(jù)庫名”);

         4、對數(shù)據(jù)表進行操作

                   將從數(shù)據(jù)庫中獲取到的資源轉(zhuǎn)換為數(shù)組

                   mysql_fetch_assoc();

                  mysql_fetch_row();

                  mysql_fetch_array();

                           

mysql_num_fields($resource);

         從資源集中獲取字段的總數(shù)

mysql_field_name($recource,$index);

         多資源集中獲取$index指定字段的名子

mysql_affected_rows();

         返回上一條執(zhí)行的sql語句,受影響的行數(shù)

mysql數(shù)據(jù)庫中有md5()函數(shù)

insert into user values(null,'li','s01',md5('123456'),1,'');

phpmd5()函數(shù)

if(md5($passwd)==$row[0])

php中的跳轉(zhuǎn):

         header(“l(fā)ocation:url”);

         header("location:http://www./index.html");

    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多