1 | <?php |
||
25 | class MongoDataSet extends DataSet |
||
26 | { |
||
27 | protected $client; |
||
28 | protected $manager; |
||
29 | protected $db; |
||
30 | protected $db_name; |
||
31 | |||
32 | function __construct($params) |
||
|
|||
33 | { |
||
34 | $this->client = null; |
||
35 | $this->mangaer = null; |
||
36 | $this->db = null; |
||
37 | $this->db_name = null; |
||
38 | if(class_exists('MongoClient')) |
||
39 | { |
||
40 | $this->setupMongoClient($params); |
||
41 | } |
||
42 | else if(class_exists('\MongoDB\Driver\Manager')) |
||
43 | { |
||
44 | $this->setupMongoManager($params); |
||
45 | } |
||
46 | else |
||
47 | { |
||
48 | require __DIR__.'/../libs/mongofill/src/functions.php'; |
||
49 | autoLoadHandler('\Data\MongofillAutoload'); |
||
50 | $this->setupMongoClient($params); |
||
51 | } |
||
52 | } |
||
53 | |||
54 | function tableExists($name) |
||
55 | { |
||
56 | $collections = $this->db->getCollectionNames(); |
||
57 | if(in_array($name, $collections)) |
||
58 | { |
||
59 | return true; |
||
60 | } |
||
61 | return false; |
||
62 | } |
||
63 | |||
64 | function getTable($name) |
||
75 | |||
76 | private function setupMongoClient($params) |
||
92 | |||
93 | private function setupMongoManager($params) |
||
109 | |||
110 | public function find($query = array(), $fields = array(), $collectionName) |
||
111 | { |
||
116 | |||
117 | public function count($query = array(), $options = array(), $collectionName) |
||
122 | } |
||
123 | /* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
||
124 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.