Home >Backend Development >PHP Tutorial > mongo数据库,该如何处理

mongo数据库,该如何处理

WBOY
WBOYOriginal
2016-06-13 13:38:31776browse

mongo数据库
如何测试mongo数据库是否连接上?
  今天刚接触mongodb。不太熟悉。
  有没有这方面的学习资料?
  谢谢!

------解决方案--------------------

PHP code

<?php class Model{
        public function creat(){
            $mongo = new Mongo('……');
            $db = $mongo->selectDB('fish_test'); //如无数据库则会自动创建
            $collection=$db->selectCollection('fish');//如无数据库表则会自动创建        
            $record=array(
                'name'=>'fish',
                'time'=>'123',
                'StartTime'=>'456',
            )

            $collection->save($record);//添加 新记录
        }
        
    }

?> <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn