安装php-mongo拓展

第一步:根据php版本,ts还是nts,vc6还是vc9,php版本x86还是x64,进行选择对应的拓展版本

thinkphp5 使用 MongoDB

thinkphp5 使用 MongoDB

第二步:放置拓展文件到php的ext拓展目录

thinkphp5 使用 MongoDB

第三步:修改php.ini配置文件,然后重启服务

thinkphp5 使用 MongoDB

重启apache服务

第四步:查看是否安装成功mongo拓展,打印phpinfo查看

thinkphp5 使用 MongoDB

 

操作原理

安装了mongo拓展之后,通过实列化mongo类可以获得操作mongodb的相关方法,使用对象调用属性和方法,可以实现管理mongodb。

增加数据

thinkphp5 使用 MongoDB

thinkphp5 使用 MongoDB

查询数据

thinkphp5 使用 MongoDB

thinkphp5 使用 MongoDB

修改数据

thinkphp5 使用 MongoDB

thinkphp5 使用 MongoDB

删除数据

thinkphp5 使用 MongoDB

thinkphp5 使用 MongoDB

对应命令行里的语句

{} 替换成为array()

:  替换成为=>

mongodb使用实列

查看数据库数据

thinkphp5 使用 MongoDB

 将数据库数据导入MongoDB

thinkphp5 使用 MongoDB

查看MongoDB内数据

thinkphp5 使用 MongoDB

thinkphp5 使用 MongoDB

进行查询

thinkphp5 使用 MongoDB

thinkphp5 使用 MongoDB

相关文章: