一、定义数据表模型

1.模型映射

要测试数据库是否正常连接,最直接的办法就是在当前控制器中实例化数据表,然后使用 dump 函数输出,查看数据库的链接状态。代码:

  1. public function testdb(){
  2.  
  3. $obj=M("User");
  4. dump($obj);
  5. }

此时浏览器输出:

object(Model)#5 (20) {
["_extModel:private"] => NULL
["db:protected"] => object(DbMysql)#7 (18) {
["dbType:protected"] => string(5) "MYSQL"
["autoFree:protected"] => bool(false)
["model:protected"] => string(7) "_think_"
["pconnect:protected"] => bool(false)
["queryStr:protected"] => string(28) "SHOW COLUMNS FROM `tpk_user`"
["modelSql:protected"] => array(1) {
["user"] => string(28) "SHOW COLUMNS FROM `tpk_user`"
}
["lastInsID:protected"] => NULL
["numRows:protected"] => int(2)
["numCols:protected"] => int(0)
["transTimes:protected"] => int(0)
["error:protected"] => string(0) ""
["linkID:protected"] => array(1) {
[0] => resource(27) of type (mysql link)
}
["_linkID:protected"] => resource(27) of type (mysql link)
["queryID:protected"] => resource(28) of type (mysql result)
["connected:protected"] => bool(true)
["comparison:protected"] => array(10) {
["eq"] => string(1) "="
["neq"] => string(2) "<>"
["gt"] => string(1) ">"
["egt"] => string(2) ">="
["lt"] => string(1) "<"
["elt"] => string(2) "<="
["notlike"] => string(8) "NOT LIKE"
["like"] => string(4) "LIKE"
["in"] => string(2) "IN"
["notin"] => string(6) "NOT IN"
}
["selectSql:protected"] => string(96) "SELECT%DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%%LIMIT% %UNION%%COMMENT%"
["bind:protected"] => array(0) {
}
}
["pk:protected"] => string(2) "id"
["tablePrefix:protected"] => string(4) "tpk_"
["name:protected"] => string(4) "user"
["dbName:protected"] => string(0) ""
["connection:protected"] => string(0) ""
["tableName:protected"] => string(0) ""
["trueTableName:protected"] => string(8) "tpk_user"
["error:protected"] => string(0) ""
["fields:protected"] => array(5) {
[0] => string(2) "id"
[1] => string(8) "username"
["_autoinc"] => bool(true)
["_pk"] => string(2) "id"
["_type"] => array(2) {
["id"] => string(7) "int(11)"
["username"] => string(11) "varchar(20)"
}
}
["data:protected"] => array(0) {
}
["options:protected"] => array(0) {
}
["_validate:protected"] => array(0) {
}
["_auto:protected"] => array(0) {
}
["_map:protected"] => array(0) {
}
["_scope:protected"] => array(0) {
}
["autoCheckFields:protected"] => bool(true)
["patchValidate:protected"] => bool(false)
["methods:protected"] => array(13) {
[0] => string(5) "table"
[1] => string(5) "order"
[2] => string(5) "alias"
[3] => string(6) "having"
[4] => string(5) "group"
[5] => string(4) "lock"
[6] => string(8) "distinct"
[7] => string(4) "auto"
[8] => string(6) "filter"
[9] => string(8) "validate"
[10] => string(6) "result"
[11] => string(4) "bind"
[12] => string(5) "token"
}
}

http://127.0.0.26/index.php/index/testdb

  1. object(Model)#5 (20) {
  2. ["_extModel:private"] => NULL
  3. ["db:protected"] => object(DbMysql)#7 (18) {
  4. ["dbType:protected"] => string(5) "MYSQL"
  5. ["autoFree:protected"] => bool(false)
  6. ["model:protected"] => string(7) "_think_"
  7. ["pconnect:protected"] => bool(false)
  8. ["queryStr:protected"] => string(28) "SHOW COLUMNS FROM `tpk_user`"
  9. ["modelSql:protected"] => array(1) {
  10. ["user"] => string(28) "SHOW COLUMNS FROM `tpk_user`"
  11. }
  12. ["lastInsID:protected"] => NULL
  13. ["numRows:protected"] => int(2)
  14. ["numCols:protected"] => int(0)
  15. ["transTimes:protected"] => int(0)
  16. ["error:protected"] => string(0) ""
  17. ["linkID:protected"] => array(1) {
  18. [0] => resource(27) of type (mysql link)
  19. }
  20. ["_linkID:protected"] => resource(27) of type (mysql link)
  21. ["queryID:protected"] => resource(28) of type (mysql result)
  22. ["connected:protected"] => bool(true)
  23. ["comparison:protected"] => array(10) {
  24. ["eq"] => string(1) "="
  25. ["neq"] => string(2) "<>"
  26. ["gt"] => string(1) ">"
  27. ["egt"] => string(2) ">="
  28. ["lt"] => string(1) "<"
  29. ["elt"] => string(2) "<="
  30. ["notlike"] => string(8) "NOT LIKE"
  31. ["like"] => string(4) "LIKE"
  32. ["in"] => string(2) "IN"
  33. ["notin"] => string(6) "NOT IN"
  34. }
  35. ["selectSql:protected"] => string(96) "SELECT%DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%%LIMIT% %UNION%%COMMENT%"
  36. ["bind:protected"] => array(0) {
  37. }
  38. }
  39. ["pk:protected"] => string(2) "id"
  40. ["tablePrefix:protected"] => string(4) "tpk_"
  41. ["name:protected"] => string(4) "user"
  42. ["dbName:protected"] => string(0) ""
  43. ["connection:protected"] => string(0) ""
  44. ["tableName:protected"] => string(0) ""
  45. ["trueTableName:protected"] => string(8) "tpk_user"
  46. ["error:protected"] => string(0) ""
  47. ["fields:protected"] => array(5) {
  48. [0] => string(2) "id"
  49. [1] => string(8) "username"
  50. ["_autoinc"] => bool(true)
  51. ["_pk"] => string(2) "id"
  52. ["_type"] => array(2) {
  53. ["id"] => string(7) "int(11)"
  54. ["username"] => string(11) "varchar(20)"
  55. }
  56. }
  57. ["data:protected"] => array(0) {
  58. }
  59. ["options:protected"] => array(0) {
  60. }
  61. ["_validate:protected"] => array(0) {
  62. }
  63. ["_auto:protected"] => array(0) {
  64. }
  65. ["_map:protected"] => array(0) {
  66. }
  67. ["_scope:protected"] => array(0) {
  68. }
  69. ["autoCheckFields:protected"] => bool(true)
  70. ["patchValidate:protected"] => bool(false)
  71. ["methods:protected"] => array(13) {
  72. [0] => string(5) "table"
  73. [1] => string(5) "order"
  74. [2] => string(5) "alias"
  75. [3] => string(6) "having"
  76. [4] => string(5) "group"
  77. [5] => string(4) "lock"
  78. [6] => string(8) "distinct"
  79. [7] => string(4) "auto"
  80. [8] => string(6) "filter"
  81. [9] => string(8) "validate"
  82. [10] => string(6) "result"
  83. [11] => string(4) "bind"
  84. [12] => string(5) "token"
  85. }
  86. }

如果没有提示错误即为成功。

M("User") 就是模型映射,M 函数等于 new Model() ,Model 类是模型的基类,也是数据库操作的基类, "User" 是该类的一个成员属性,表示模型名称,模型名称与数据库中的数据表进行映射。注意:User "U" 要大写,数据库中此时应该存在一张 user 表,系统会根据配置文件中的设置给 user 表添加前缀,例如 tpk_user。如果不需要为表添加前缀,将模型名称首字母改为小写,例如 M("user")。

2.自定义模型

D 函数用于快速实例化自定义模型,可以进行复杂的数据库操作,比如数据检验、数据缓存、数据加工等。自定义模型存放在 Lib/Model 目录下,例如为数据表 tpk_article 数据表建立模型映射,则需要创建 ArticleModel.class.php,然后使用 D 函数进行实例化,ArticleModel 模型将与 tpk_article 表进行映射。

例:使用 select() 输出 tpk_article 表的数据 ( select() 方法用于列出所有符合条件的数据 ) :

  1. class IndexAction extends Action {
  2. public function article(){
  3.  
  4. $obj=D("Article");
  5. $rows=$obj->select();
  6. dump($rows);
  7. }
  8. }

浏览器输出:

array(6) {
[0] => array(7) {
["id"] => string(1) "1"
["title"] => string(4) "test"
["content"] => string(12) "test_content"
["category"] => string(13) "test_category"
["area"] => string(6) "北京"
["add_user"] => string(5) "admin"
["add_time"] => string(19) "2014-11-20 23:03:44"
}
[1] => array(7) {
["id"] => string(1) "2"
["title"] => string(12) "吼吼吼吼"
["content"] => string(18) "任溶溶柔然人"
["category"] => string(14) "test_category2"
["area"] => string(6) "河北"
["add_user"] => string(5) "admin"
["add_time"] => string(19) "2014-11-22 15:16:12"
}
[2] => array(7) {
["id"] => string(1) "4"
["title"] => string(7) "test2_m"
["content"] => string(4) "haha"
["category"] => string(0) ""
["area"] => string(6) "福建"
["add_user"] => NULL
["add_time"] => string(19) "2014-11-22 11:44:26"
}
[3] => array(7) {
["id"] => string(1) "5"
["title"] => string(2) "22"
["content"] => NULL
["category"] => string(0) ""
["area"] => string(6) "福建"
["add_user"] => NULL
["add_time"] => string(19) "2014-11-22 12:40:58"
}
[4] => array(7) {
["id"] => string(1) "6"
["title"] => string(1) "1"
["content"] => string(1) "2"
["category"] => string(0) ""
["area"] => string(6) "福建"
["add_user"] => NULL
["add_time"] => NULL
}
[5] => array(7) {
["id"] => string(1) "7"
["title"] => string(6) "lalala"
["content"] => string(6) "hohoho"
["category"] => string(0) ""
["area"] => string(6) "北京"
["add_user"] => NULL
["add_time"] => NULL
}
}

http://127.0.0.26/index.php/index/article

  1. array(6) {
  2. [0] => array(7) {
  3. ["id"] => string(1) "1"
  4. ["title"] => string(4) "test"
  5. ["content"] => string(12) "test_content"
  6. ["category"] => string(13) "test_category"
  7. ["area"] => string(6) "北京"
  8. ["add_user"] => string(5) "admin"
  9. ["add_time"] => string(19) "2014-11-20 23:03:44"
  10. }
  11. [1] => array(7) {
  12. ["id"] => string(1) "2"
  13. ["title"] => string(12) "吼吼吼吼"
  14. ["content"] => string(18) "任溶溶柔然人"
  15. ["category"] => string(14) "test_category2"
  16. ["area"] => string(6) "河北"
  17. ["add_user"] => string(5) "admin"
  18. ["add_time"] => string(19) "2014-11-22 15:16:12"
  19. }
  20. [2] => array(7) {
  21. ["id"] => string(1) "4"
  22. ["title"] => string(7) "test2_m"
  23. ["content"] => string(4) "haha"
  24. ["category"] => string(0) ""
  25. ["area"] => string(6) "福建"
  26. ["add_user"] => NULL
  27. ["add_time"] => string(19) "2014-11-22 11:44:26"
  28. }
  29. [3] => array(7) {
  30. ["id"] => string(1) "5"
  31. ["title"] => string(2) "22"
  32. ["content"] => NULL
  33. ["category"] => string(0) ""
  34. ["area"] => string(6) "福建"
  35. ["add_user"] => NULL
  36. ["add_time"] => string(19) "2014-11-22 12:40:58"
  37. }
  38. [4] => array(7) {
  39. ["id"] => string(1) "6"
  40. ["title"] => string(1) "1"
  41. ["content"] => string(1) "2"
  42. ["category"] => string(0) ""
  43. ["area"] => string(6) "福建"
  44. ["add_user"] => NULL
  45. ["add_time"] => NULL
  46. }
  47. [5] => array(7) {
  48. ["id"] => string(1) "7"
  49. ["title"] => string(6) "lalala"
  50. ["content"] => string(6) "hohoho"
  51. ["category"] => string(0) ""
  52. ["area"] => string(6) "北京"
  53. ["add_user"] => NULL
  54. ["add_time"] => NULL
  55. }
  56. }

例2:让 tpk_article 表的内容根据客户所在的地区显示当地的新闻:

ArticleModel.class.php:

  1. <?php
  2. class ArticleModel extends Model{
  3.  
  4. public function article(){
  5.  
  6. $rows=$this->where("area='{$this->checkUserArea()}'")->select();
  7. return $rows;
  8. }
  9.  
  10. protected function checkUserArea(){
  11.  
  12. return "北京";
  13. }

控制器代码:

IndexAction.class.php:

  1. <?php
  2. class IndexAction extends Action {
  3.  
  4. $obj=D("Article");
  5. $rows=$obj->article();
  6. $this->assign("list",$rows);
  7. $this->display();

同时视图代码:

TPL/Index/article.html:

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <volist name="list" id="vo">
  6. <li><{$vo.title}> - <{$vo.area}> - <{$vo.content}></li>
  7. </volist>
  8.  
  9. </body>
  10. </html>

附:数据表 tpk_article 的表结构为:

总结:自定义模型映射,一个模型对应一个数据表,所有增删改查都在模型类中完成。M 实例化的参数是数据库的表名,D 实例化的是自己在 model 文件夹下建立的模型文件。

3.create 方法

TP 对数据的插入和更新都做了高度封装:提供了 create() 方法用于创建数据对象。

概念:数据对象 —— 数据字段与数据表之间的关系,数据会被映射为类成员,再与数据表映射,最后实现数据的插入或更新。

create() 方法是连贯操作、CURD 操作的集合 ( 包括数据创建、数据检验、表单验证、自动完成等 )。

cerate() 的数据源由 POST 表单提供,比如表单中有 username 表单元素,则该元素会被自动映射为数据表中的 username 字段。数据对象创建成功以后,对象被存放于内存中。

例:添加数据

控制器:IndexAction,动作:add_article,代码:

IndexAction.class.php:

  1. <?php
  2. class IndexAction extends Action {
  3.  
  4. Public function add_article(){
  5.  
  6. $this->display();
  7. }

视图: Tpl/Index/add_article.html:

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <form method="post" action="__URL__/add">
  6.  
  7. <input type="text" name="title" placeholder="标题"><br><br>
  8. <textarea name="content" id="content" placeholder="内容"></textarea><br><br>
  9. <input type="submit" name="submit" value="提交">
  10.  
  11. </form>
  12.  
  13. </body>
  14. </html>

__URL__/add 表示当前控制器的 add 动作。

add 动作代码:

  1. <?php
  2. class IndexAction extends Action {
  3.  
  4. public function add(){
  5.  
  6. //表单处理
  7. $articleObj = M('Article');
  8. $articleObj->create();
  9. $articleObj->add_time = date("Y-m-d H:i:s",time());
  10. if($articleObj->add()){
  11.  
  12. $this->success("数据添加成功");
  13. }else{
  14.  
  15. $this->error("数据添加失败");
  16. }
  17. }

例子结束。

4.模型属性( Model )

_map 属性:字段映射

为了避免前台表单元素与数据库字段名相同而使数据库字段暴露,可以修改前台表单元素的 name,同时在 Model 中使用 _map 属性。代码:

视图:Tpl/Index/add_article.html:

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <form method="post" action="__URL__/add">
  6.  
  7. <input type="text" name="subject" placeholder="标题"><br><br>
  8. <textarea name="textEdit" id="content" placeholder="内容"></textarea><br><br>
  9. <input type="submit" name="submit" value="提交">
  10.  
  11. </form>
  12.  
  13. </body>
  14. </html>

模型:ArticleModel.class.php:

  1. <?php
  2. class ArticleModel extends Model{
  3.  
  4. //使用_map属性(字段映射)将表单元素映射为相应表字段
  5. protected $_map = array(
  6.  
  7. "subject"=>"title",
  8. "textEdit"=>"content"
  9. );
  10.  
  11. }

控制器:IndexAction.class.php:

  1. <?php
  2.  
  3. class IndexAction extends Action {
  4.  
  5. $articleObj = D("Article");
  6. $articleObj->create();
  7. $articleObj->add_time = date("Y-m-d H:i:s",time());
  8. if($articleObj->add()){
  9.  
  10. $this->success("数据添加成功");
  11. }else{
  12.  
  13. $this->error("数据添加失败");
  14. }
  15. }

例子结束。

二、基础模型

1.连贯操作

连贯方法除了 select() 方法外,其他的连贯方法不区分前后顺序。

例:

  1. $rows=$obj->where("add_user='dee'")->order("add_time desc")->limit(10)->select();

2.CURD

① 创建数据 add()

  1. <?php
  2.  
  3. class IndexAction extends Action {
  4.  
  5. public function post(){
  6.  
  7. $articleObj = D("Article");
  8. $data['title'] = $_POST['subject'];
  9. $data['content'] = $_POST['textEdit'];
  10. $data['add_time'] = date("Y-m-d H:i:s",time());
  11. if($articleObj->add($data)){
  12.  
  13. $this->success("数据添加成功");
  14. }else{
  15.  
  16. $this->error("数据添加失败");
  17. }
  18. }
  19. }

另一个例子:

  1. <?php
  2.  
  3. class IndexAction extends Action {
  4.  
  5. public function post(){
  6.  
  7. $articleObj = D("Article");
  8. $data['title'] = $_POST['subject'];
  9. $data['content'] = $_POST['textEdit'];
  10. $data['add_time'] = date("Y-m-d H:i:s",time());
  11. if($articleObj->data($data)->add()){
  12.  
  13. $this->success("数据添加成功");
  14. }else{
  15.  
  16. $this->error("数据添加失败");
  17. }
  18. }
  19. }

② 更新数据 save()

  1. <?php
  2.  
  3. class IndexAction extends Action {
  4. public function post2(){
  5.  
  6. $articleObj = M("Article");
  7. $data['id'] = 2;
  8. $data['title'] = $_POST['subject'];
  9. $data['content'] = $_POST['textEdit'];
  10. $data['area'] = '河北';
  11. $data['add_time'] = date("Y-m-d H:i:s",time());
  12. if($articleObj->save($data)){
  13.  
  14. $this->success("数据修改成功");
  15. }else{
  16.  
  17. $this->error("数据修改失败");
  18. }
  19. }
  20. }

③ 读取数据 select 和 getFiled

getField 例子:

  1. <?php
  2.  
  3. class IndexAction extends Action {
  4.  
  5. public function post3(){
  6.  
  7. $articleObj = M("Article");
  8. if($articleObj->where("id=3")->setField("content","{$_POST['subject']}")){
  9.  
  10. $this->success("数据修改成功");
  11. }else{
  12.  
  13. $this->error("数据修改失败");
  14. }
  15. }

④ 删除数据 delete

  1. <?php
  2.  
  3. class IndexAction extends Action {
  4.  
  5. public function delete(){
  6.  
  7. $articleObj = M("Article");
  8. if($articleObj->where("id=".$_GET['id'])->delete()){
  9.  
  10. $this->success("数据删除成功");
  11. }else{
  12.  
  13. $this->error("数据删除失败");
  14. }
  15. }

3.查询语言

例子:

  1. <?php
  2.  
  3. class IndexAction extends Action {
  4.  
  5. public function archives(){
  6.  
  7. $obj = M("Archives");
  8. // $data['writer'] = array("eq","网络营销中心");
  9. // $data['title'] = array("like","精诚%");
  10. $data['id'] = array("lt","100");
  11. $rows=$obj->where($data)->select();
  12.  
  13. $count=$obj->where($data)->count();
  14. $tb=C("DB_PREFIX");
  15.  
  16. $this->assign("list",$rows);
  17. $this->assign("count",$count);
  18. $this->assign("tb",$tb);
  19. $this->display("Article");
  20. }
  21.  
  22. public function archives2(){
  23.  
  24. $obj = M("Archives");
  25. $data['id'] = array(array("lt","1034"),array("GT","1029"),"and");
  26. $rows=$obj->where($data)->select();
  27. $this->assign("list",$rows);
  28. $this->display("Article");
  29. }

可以在控制器中使用 echo $obj->getLastSql(); 查看转换后的 SQL 语句。

参考资料:《PHP MVC 开发实战》

ThinkPHP 数据库操作之数据表模型和基础模型 ( Model )的更多相关文章

  1. ThinkPHP 学习笔记 ( 三 ) 数据库操作之数据表模型和基础模型 ( Model )

    //TP 恶补ing... 一.定义数据表模型 1.模型映射 要测试数据库是否正常连接,最直接的办法就是在当前控制器中实例化数据表,然后使用 dump 函数输出,查看数据库的链接状态.代码: publ ...

  2. 孤荷凌寒自学python第四十九天继续研究跨不同类型数据库的通用数据表操作函数

    孤荷凌寒自学python第四十九天继续研究跨不同类型数据库的通用数据表操作函数 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 今天继续建构自感觉用起来顺手些的自定义模块和类的代码. 不同类型 ...

  3. thinkPHP数据库操作

    thinkPHP如果要对数据库操作,一般来说首先要做的是在配置文件中链接数据库,然后用M方法实例化一张表,然后就是对表的操作了 可以开启调试功能查看程序执行的sql语句: 1.开启调试功能(默认是已经 ...

  4. ThinkPHP 数据库操作(三) : 查询方法、查询语法、链式操作

    查询方法 条件查询方法 where 方法 可以使用 where 方法进行 AND 条件查询: Db::table('think_user') ->where('name','like','%th ...

  5. 孤荷凌寒自学python第四十八天通用同一数据库中复制数据表函数最终完成

    孤荷凌寒自学python第四十八天通用同一数据库中复制数据表函数最终完成 (完整学习过程屏幕记录视频地址在文末) 今天继续建构自感觉用起来顺手些的自定义模块和类的代码. 今天经过反复折腾,最终基本上算 ...

  6. 孤荷凌寒自学python第四十七天通用跨数据库同一数据库中复制数据表函数

    孤荷凌寒自学python第四十七天通用跨数据库同一数据库中复制数据表函数 (完整学习过程屏幕记录视频地址在文末) 今天继续建构自感觉用起来顺手些的自定义模块和类的代码. 今天打算完成的是通用的(至少目 ...

  7. 0420-mysql命令(数据库操作层级,建表,对表的操作)

    注意事项: 符号必须为英文. 数据库操作层级: 建表大全: #新建表zuoye1:drop table if exists zuoye1;create table zuoye1(    id int ...

  8. android 一个SQLite数据库多个数据表的基本使用框架 (带demo)

    android 一个SQLite数据库多个数据表(带demo) 前言        demo演示        一.搭建        二.建立实体类        三.建立数据库操作类        ...

  9. 统计各个数据库的各个数据表的总数,然后写入到excel中

    1.最近项目基本进入最后阶段了,然后会统计一下各个数据库的各个数据表的数据量,开始使用的报表工具,report-designer,开源的,研究了两天,发现并不是很好使,最后自己下班回去,晚上思考,想着 ...

随机推荐

  1. [android]解析XML文件的方法有三种:PULL,DOM,SAM

    PULL 的工作原理: XML pull提供了开始元素和结束元素.当某个元素开始时,可以调用parser.nextText从XML文档中提取所有字符数据.当解析到一个文档结束时,自动生成EndDocu ...

  2. qlserver排序规则在全角与半角处理中的应用

    --1.查询区分全角与半角字符--测试数据DECLARE @t TABLE(col varchar(10))INSERT @t SELECT 'aa'UNION ALL SELECT 'Aa'UNIO ...

  3. (二) solr 索引数据导入:xml格式

    xml 是最常用的数据索引格式,不仅可以索引数据,还可以对文档与字段进行增强,从而改变它们的重要程度. 下面就是具体的实现方式: schema.xml的字段配置部分如下: <field name ...

  4. oracle centos 静默安装

    http://blog.csdn.net/tongzidane/article/details/43852705 静默安装Oracle 11G过程中提示:Exception in thread &qu ...

  5. 1975: [Sdoi2010]魔法猪学院

    k短路,只会写A*的飘过..priority_queue超空间差评!

  6. 【PAT】1015 德才论 (25)(25 分)

    1015 德才论 (25)(25 分) 宋代史学家司马光在<资治通鉴>中有一段著名的“德才论”:“是故才德全尽谓之圣人,才德兼亡谓之愚人,德胜才谓之君子,才胜德谓之小人.凡取人之术,苟不得 ...

  7. day5模块学习--yaml文件处理

    yaml文件处理(http://pyyaml.org/wiki/PyYAMLDocumentation)     摘要: 本文讲的是yaml在python上的使用教程详解, YAML是一种容易人类阅读 ...

  8. GPS数据包格式及数据包解析

    GPS数据包解析 GPS数据包解析 目的 GPS数据类型及格式 数据格式 数据解释 解析代码 结构体定义 GPRMC解析函数 GPGGA解析函数 测试样例输出 gps数据包格式 gps数据解析 车联网 ...

  9. JAVAEE——Solr:安装及配置、后台管理索引库、 使用SolrJ管理索引库、仿京东的电商搜索案例实现

    1 学习回顾 1. Lucene  是Apache开源的全文检索的工具包 创建索引 查询索引 2. 遇到问题? 文件名 及文件内容  顺序扫描法  全文检索 3. 什么是全文检索? 这种先创建索引 再 ...

  10. Ubuntu下修改为永久DNS的方法

    安装好Ubuntu之后设置了静态IP地址,再重启后就无法解析域名.想重新设置一下DNS,打开/etc/resolv.conf cat /etc/resolv.conf # Dynamic resolv ...