Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add multiple configures support of model

  • Loading branch information...
commit 315f73950b8c204b12711a8477dc07f1a05bfab1 1 parent 75e150f
Jace Ju jaceju authored

Showing 2 changed files with 5 additions and 16 deletions. Show diff stats Hide diff stats

  1. +2 2 model.php
  2. +3 14 mongodb.php
4 model.php
@@ -21,7 +21,7 @@ class Model {
21 21 *
22 22 * @var string
23 23 */
24   - public $connection = 'mongor';
  24 + public $connection = 'database';
25 25
26 26 /**
27 27 * Indicates if the model exists in the database.
@@ -115,7 +115,7 @@ public function __construct($connection = NULL)
115 115
116 116 if (is_string($this->connection))
117 117 {
118   - $this->connection = new MongoDB;
  118 + $this->connection = new MongoDB($this->connection);
119 119 }
120 120
121 121 if (is_null(static::$collection))
17 mongodb.php 100755 → 100644
@@ -43,12 +43,12 @@ class MongoDB {
43 43 * @param $name
44 44 * @param array $config
45 45 */
46   - public function __construct()
  46 + public function __construct($config_name = 'database')
47 47 {
48 48
49   - $this->_config = Config::get('mongor::database');
  49 + $this->_config = Config::get('mongor::' . $config_name);
50 50
51   - $this->connect();
  51 + $this->connect();
52 52
53 53 return $this;
54 54 }
@@ -323,8 +323,6 @@ public function remove_file( array $criteria = array(), array $options = array()
323 323 /* Run Command */
324 324 protected function _call($command, array $arguments = array(), array $values = NULL)
325 325 {
326   - $start = microtime(true);
327   -
328 326 $this->_connected OR $this->connect();
329 327
330 328 extract($arguments);
@@ -396,16 +394,7 @@ protected function _call($command, array $arguments = array(), array $values = N
396 394 break;
397 395 }
398 396
399   - $this->log($command, $start, $arguments);
400   -
401 397 return $r;
402 398 }
403   -
404   - protected function log($command, $start, $arguments) {
405   -
406   - $time = number_format((microtime(true) - $start) * 1000, 2);
407   -
408   - \Laravel\Event::fire('laravel.mongoquery', array($this->_db, $command, $arguments, $time));
409   - }
410 399 }
411 400 ?>

0 comments on commit 315f739

Please sign in to comment.
Something went wrong with that request. Please try again.