mysql非常全的和完整的总结

数据类型

类型 备注
tinyint/smallint/mediumint/int/bigint 1B/2B/3B/4B/8B
float/double 单精度/双精度浮点型
decimal 不会产生精度丢失的单精度/双精度浮点型
date 日期类型
time 时间类型
datetime/TimeStamp 日期时间类型/TimeStamp(登录时间,自动填充)
year 年类型
char 定长字符串类型
varchar 可变长字符串类型
tinyblob/blob/mediumblob/longblob 255B/64K/16M/4G大小图片/音乐二进行数据
tinytext/text/mediumtext/longtext 255B/64K/16M/4G大小的文本数据

Read More

php之mongodb插入数据后如何返回当前插入记录ID

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php  
/**
*插入记录
*参数:
*$table_name:表名
*$record:记录
*
*返回值:
*成功:true
*失败:false
*/
function insert($table_name,$record){
$dbname = $this->curr_db_name;
try{
$this->mongo->$dbname->$table_name->insert($record,array('safe'=>true));//执行安全写入的方法
return true;
}catch(MongoCursorException $e){
$this->error = $e->getMessage();
return false;
}
}

?>

如上所示,参数$record实际上是个指针引用,当插入成功后$record数组中就会自动返回_id

Read More