mysql基本操做

创建数据库timelinedb:

create database timelinedb;

创建一个用户给他提供操作my_db的权利(用户名:mydbuser,密码:himydb):

grant select, insert, delete, update

on timelinedb.*

to mydbuser identified by 'himydb';

选择要操作的数据库:

use timelinedb;

给timelinedb创建表:

create table users
( userid int unsigned not null auto_increment primary key,
username char(50) not null,
email char(100) not null,
password char(50) not null
);

create table pages
( versionid int unsigned not null auto_increment primary key,
version bigint not null,
time datetime not null,
path char not null,
information longtext,
pageid int not null
);

如果保存较长的字符串,可用text/longtext代替char。

修改定义的列:

alter table pages change path path varchar(200) not null;

给表users插入数据:

insert into users values
(NULL, 'timeline', 'timeline@timeline.com', 'timeline');

 清空一个表:

truncate table mytable;

PHP操作

选择数据:

$query = "select version, versionid from pages where version = (select max(version) from pages)";
$result=mysql_query($query);
if(mysql_num_rows($result) > 0){
while ($row = mysql_fetch_assoc($result)) {
return $row['version'];
}

注:存入的数据中有'\',则要加转义字符,应写成'\\'。

转载于:https://www.cnblogs.com/liubingna/p/3278190.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值