易截截图软件、单文件、免安装、纯绿色、仅160KB

sqlite和pdo mysql的数据库操作

今天的学习内容是sqlite和PDO mysql。
用自己的话说说两个东西吧:
sqlite算是一种不系统的数据库存储方式,它的存放格式是一个.db后缀的文件,在php中它存放在当前的目录下,貌似不用用户名密码,安全性较低,却比较方便。PHP5中自带的一些系统函数,都是以sqlite_开头的。
PDO全称PHP Data Object,顾名思义就是PHP的一种系统对象?在操作用也是以一个类为开始。类似mysql的方式。
主要摘录一下函数吧:
1. sqlite:
$db = sqlite_open("php100.db");
$sql = "select * from test";
$result = sqlite_query($db,$sql);
$row = sqlite_fetch_array($result);
print_r($row);

2. PDO mysql:
$db = new PDO("mysql:host=localhost;dbname=student",'root','');
$rs = $db->query("SELECT * from testmem");
while($row = $rs->fetch()){
print_r($row);
echo "<hr size=1>";
}


相关文档:

mysql 安装

一、安装
#
yum -y install mysql-server
二、配置
# vi /etc/my.cnf  ← 编辑MySQL的配置文件
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility pack ......

MySQL 严格模式 sql_mode

虽然说我们尽量在写程序的时候控制插入到数据库的数据,而不要用数据库去判断数据的对错,但是有时候为了方便还是需要数据库自身的容错能力来帮助我们达到目的的。举例说明:
创建如下数据表
CREATE TABLE `book` (
  `id` int(11) default NULL,
  `num` int(11) unsigned default NULL
) ENGINE=InnoDB DE ......

定制你的MySQL命令行

我在登录MySQL后的命令行是这个样子的:
warmbupt@pchuang:/windows/MyCode/SS$ mysql -u root -ppassw0rd
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.1.37-1ubuntu5.1 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the curr ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号