最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
tp5(thinkPHP5)怎么操作mongoDB数据库
时间:2022-06-24 18:41:34 编辑:袖梨 来源:一聚教程网
本文介绍了tp5(thinkPHP5)操作mongoDB数据库的教程,给有需要的朋友参考一下。
1.通过composer安装
composer require mongodb/mongodb
2.使用
mongoManager = new Manager($this->getUri());
    $this->mongoCollection = new Collection($this->mongoManager, "mldn","dept");
  }
  public function test() {
    // 读取一条数据
    $data = $this->mongoCollection->findOne();
    print_r($data);
  }
  protected function getUri()
  {
    return getenv('MONGODB_URI') ?: 'mongodb://127.0.0.1:27017';
  }
}
相关文章
- 三角洲行动兑换码是什么 三角洲行动最新2025兑换码一览 10-30
- 原神圣祭者的辉杖武器介绍 10-30
- 王者万象棋萌新玩法教学 10-30
- 洛克王国世界家园等级怎么提升-家园等级提升方法 10-30
- 崩坏星穹铁道3.7上半卡池抽取建议 10-30
- 二重螺旋垃圾桶有什么彩蛋 10-30
 
             
                                 
                                 
                                 
                                 
                                            
                                         
                                            
                                         
                                            
                                         
                                            
                                         
                                            
                                         
                                            
                                         
                                            
                                         
                                            
                                         
                                            
                                         
                                            
                                        
