标签:
高级篇中将涉及数据库的使用以及Cookie和Session会话,提高PHP的开发效率和运行效率
PHP程序员需要掌握的MySQL操作
连接MySQL DB:
数据定义语言(DDL)
CREATE DATABASE [IF NO EXISTS] DatabaseName
CREATE TABLE [IF NOT EXISTS] TableName ( colname1 type [property] [index], colname2 type [property] [index], ... )[tableType] [tableCharSet];
※任何数据类型以字符串的形式存入,都可以自动转换类型
※将时间保存为php时间戳,方便运算
数据字段属性
索引
数据表类型及存储位置
| 功能 | MyISAM | InnoDB |
| 事务处理 | 不支持 | 支持 |
| 数据行锁定 | 不支持 | 支持 |
| 外键约束 | 不支持 | 支持 |
| 表空间占用 | 相对较小 | 较大 |
| 全文索引 | 支持 | 不支持 |
MySQL默认字符集
数据操作语言(DML)
数据查询语言(DQL)
数据控制语言(DCL)
MySQL内置函数
strcmp(s1,s2):如果S1比S2小,返回-1;如果S1比S2大则返回1;如果相等则返回0(比较的是ASCII码)
PHP操作数据库
mysqli操作数据库
PDO
mamcache/memcached
基于libevent事件,所以必须先安装libevent库
| Command | Description | Example |
|---|---|---|
| get | Reads a value | get mykey |
| set | Set a key unconditionally | set mykey 0 60 5 |
| add | Add a new key | add newkey 0 60 5 |
| replace | Overwrite existing key | replace key 0 60 5 |
| append | Append data to existing key | append key 0 60 15 |
| prepend | Prepend data to existing key | prepend key 0 60 15 |
| incr | Increments numerical key value by given number | incr mykey 2 |
| decr | Decrements numerical key value by given number | decr mykey 5 |
| delete | Deletes an existing key | delete mykey |
| flush_all | Invalidate specific items immediately | flush_all |
| Invalidate all items in n seconds | flush_all 900 | |
| stats | Prints general statistics | stats |
| Prints memory statistics | stats slabs | |
| Prints memory statistics | stats malloc | |
| Print higher level allocation statistics | stats items | |
| stats detail | ||
| stats sizes | ||
| Resets statistics | stats reset | |
| version | Prints server version. | version |
| verbosity | Increases log level | verbosity |
| quit | Terminate telnet session | quit |
PHP中使用memcache
1 <?php 2 $memcache = new Memcache; 3 $memcache->connect("localhost",11211) or die("could not connect");
会话控制:面向连接的可靠的连接方式,通过会话控制,判断用户的登录行为
至此,PHP的基础学习算是完成了,需要多做多学,方能提高!
标签:
原文地址:http://www.cnblogs.com/HuangWj/p/4371450.html