菜鸟自学lamp笔记三

by kevin 5. 十一月 2014 23:16 >
碰到一个恶心的问题: 无法保存包含中文的字符串,查了很久,就懂的是字符集的问题。 mysql的字符集在server,database,table,column都可以定义。 查看字符集: 数据库级别 1: SELECT default_character_set_name FROM information_schema.SCHEMATA S 2: WHERE schema_name = "schemaname"; 表级别 1: SELECT CCSA.character_set_name FROM information_schema.`TABLES` T, 2: information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA 3: WHERE CCSA.collation_name = T.table_collation 4: AND T.table_schema = "schemaname" 5: AND T.table_name = "tablename"; 列级别 1: SELECT character_set_name FROM information_schema.`COLUMNS` C 2: WHERE table_schema = "schemaname" 3: AND table_name = "tablename" 4: AND column_name = "columnname"; 修改数据库字符集: 1: ALTER DATABASE db_name DEFAULT CHARACTER SET character_name [COLLATE ...]; 把表默认的字符集和所有字符列(CHAR,VARCHAR,TEXT)改为新的字符集: 1: ALTER TABLE tbl_name CONVERT TO CHARACTER SET character_name [COLLATE ...] 只是修改表的默认字符集: 1: ALTER TABLE tbl_name DEFAULT CHARACTER SET character_name [COLLATE...]; 修改列的字符集: 1: ALTER TABLE tbl_name CHANGE c_name c_name CHARACTER SET character_name [COLLATE ...];

Tags: ,

lamp

菜鸟自学lamp笔记二

by kevin 5. 十一月 2014 23:05 >
一些常用的函数: 返回对象的类名 string get_class ([ object $obj ] ) 获取变量的类型 string gettype ( mixed $var ) 检查类是否已定义 bool class_exists ( string $class_name [, bool $autoload = true ] ) 检查类的方法是否存在 bool method_exists ( mixed $object , string $method_name )

Tags: ,

lamp

菜鸟自学lamp笔记一

by kevin 5. 十一月 2014 22:49 >
日期格式化: 有两个函数:date(format,timestamp)和date_format(object,format) 共同点:都有format参数 差别在于: 1. 参数顺序 2. 参数类型date需要一个timestamp,而date_format需要一个DateTime实例。

Tags: ,

lamp