Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting driver wide collection options for safe, fsync and timeout. #32

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5a2c3dd
Changes allow setting of driver wide colleciton options for safe, fsy…
elricho Sep 2, 2011
9b2d990
Fixed bug in insert introduced in previous commit.
elricho Sep 5, 2011
afe9b9e
Updated to use collectionOptions on a per collection basis rather tha…
elricho Sep 11, 2011
fc17456
Library ported from using php-mongo extebsion to new php-mongodb exte…
Oct 31, 2016
c1a6c8b
Remove outdated directories.
Oct 31, 2016
437a15e
Remove outdated docs.
Oct 31, 2016
a61f886
Remove outdated Cakephp 1.3 samples.
Oct 31, 2016
ae89f69
Remove debug statements.
Oct 31, 2016
ca4d05c
Update readme.
Oct 31, 2016
0f4daec
Updated readme.
Oct 31, 2016
91412f9
Cleanup JSON for Packagist
Oct 31, 2016
39e9906
Remove uppercase chars from package name ! Doh, i always forget this.
Oct 31, 2016
d52cce6
Adjust composer instructions for lowercase composer name.
Oct 31, 2016
ec2eae5
Add Travis CI
Nov 1, 2016
acc2fa9
Install php-mongodb extension for php 5.6
Nov 1, 2016
5b9ef91
Use correct path to tests.
Nov 1, 2016
7e8513d
Remove debug from tests.
Nov 1, 2016
e784112
BugFix : Change MongoDate to new class MongoDB\BSON\UTCDateTime.
Nov 1, 2016
228ac24
BugFix : Replace MongoDate with MongoDB\BSON\UTCDateTime
Nov 1, 2016
20129c0
BugFIx : Use MongoDB::MONGODB_VERSION constant to get the driver vers…
Nov 1, 2016
70e745e
BugFix : Update exceptions to new exception classes.
Nov 1, 2016
eed4233
Have composer install deps.
Nov 1, 2016
034f278
Ensure composer autoload.php executes before tests run.
Nov 1, 2016
83621ba
Fix previous blunder - doh !
Nov 1, 2016
d378b79
Add composer autoload to cakephp bootstrap.
Nov 1, 2016
e350dc0
Update composer.json for correct phpunit version. (Cakephp 2.x needs …
Nov 1, 2016
a696900
Remove reference to mysql.
Nov 1, 2016
fc6357a
Cleanup better after tests.
Nov 1, 2016
ca8bdaf
BugFix : testCreateConnectionName using incorrect datasource name.
Nov 1, 2016
fcea761
Fix datasource issues with $test database defaults.
Nov 1, 2016
7c95938
Added debug to tests - tracing a travis issue.
Nov 2, 2016
3897805
Install Mongodb 3.2 (Travis uses 2.4).
Nov 2, 2016
b6a1d37
Don't drop system collections.
Nov 2, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
language: php

php:
- 5.6
- 7.0

env:
global:
- PLUGIN_NAME=MongoDBLib
- DATASOURCE_NAME=MongodbSource
- REQUIRE=""

matrix:
- CAKE_VERSION=2.8
- CAKE_VERSION=2.9

addons:
apt:
sources:
- mongodb-upstart
- mongodb-3.2-precise
packages:
- mongodb-org-server
- mongodb-org-shell

matrix:
include:
- php: 5.6
env:
- CAKE_VERSION=2.8
- CODECOVERAGE=1
- php: 5.6
env:
- PHPCS=1

before_script:
- if [[ $TRAVIS_PHP_VERSION =~ 5.6 ]] ; then echo yes | pecl install mongodb; fi;
- echo "extension=mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- git clone -b master https://github.com/FriendsOfCake/travis.git --depth 1 ../travis
- travis_wait ../travis/before_script.sh
- travis_retry composer install
- echo "require APP . 'vendor' . DS . 'autoload.php';" >> ../cakephp/app/Config/bootstrap.php

script:
- if [ -d ../cakephp/app ]; then cd ../cakephp/app; fi; ./Console/cake test $PLUGIN_NAME Datasource/$DATASOURCE_NAME

notifications:
email: false
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SchemalessBehavior extends ModelBehavior {
* @return void
* @access public
*/
public function setup(&$Model, $config = array()) {
public function setup(Model $Model, $config = array()) {
//$this->settings[$Model->alias] = array_merge($this->_defaultSettings, $config);
}

Expand All @@ -81,7 +81,7 @@ public function setup(&$Model, $config = array()) {
* @return void
* @access public
*/
public function beforeSave(&$Model) {
public function beforeSave(Model $Model, $options = array()) {
$Model->cacheSources = false;
$Model->schema(true);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class SqlCompatibleBehavior extends ModelBehavior {
* @return void
* @access public
*/
public function setup(&$Model, $config = array()) {
public function setup(Model $Model, $config = array()) {
$this->settings[$Model->alias] = array_merge($this->_defaultSettings, $config);
}

Expand All @@ -91,7 +91,7 @@ public function setup(&$Model, $config = array()) {
* @return void
* @access public
*/
public function afterFind(&$Model, $results, $primary) {
public function afterFind(Model $Model, $results, $primary=false) {
if ($this->settings[$Model->alias]['convertDates']) {
$this->convertDates($results);
}
Expand All @@ -108,30 +108,55 @@ public function afterFind(&$Model, $results, $primary) {
* @return void
* @access public
*/
public function beforeFind(&$Model, $query) {
public function beforeFind(Model $Model, $query) {
if (is_array($query['order'])) {
$this->_translateOrders($Model, $query['order']);
}
if (is_array($query['conditions']) && $this->_translateConditions($Model, $query['conditions'])) {
return $query;
}
return true;
return $query;
}

/**
* Convert MongoDate objects to strings for the purpose of view simplicity
*
* @param mixed $results
* @return void
* @access public
* @access protected
*/
public function convertDates(&$results) {
protected function convertDates(&$results) {
if (is_array($results)) {
foreach($results as &$row) {
$this->convertDates($row);
}
} elseif (is_a($results, 'MongoDate')) {
$results = date('Y-M-d h:i:s', $results->sec);
} elseif (is_a($results, 'MongoDB\BSON\UTCDateTime')) {
$results = date('Y-M-d h:i:s', $results->toDateTime()->getTimestamp());
}
}


/**
* translateOrders method
* change order syntax from SQL style to Mongo style
*
* @param mixed $Model
* @param mixed $orders
* @return void
* @access protected
*/
protected function _translateOrders(Model &$Model, &$orders) {
if(!empty($orders[0])) {
foreach($orders[0] as $key => $val) {
if(preg_match('/^(.+) (ASC|DESC)$/i', $val, $match)) {
$orders[0][$match[1]] = $match[2];
unset($orders[0][$key]);
}
}
}
}


/**
* translateConditions method
*
Expand All @@ -142,7 +167,7 @@ public function convertDates(&$results) {
* @return void
* @access protected
*/
protected function _translateConditions(&$Model, &$conditions) {
protected function _translateConditions(Model &$Model, &$conditions) {
$return = false;
foreach($conditions as $key => &$value) {
$uKey = strtoupper($key);
Expand Down Expand Up @@ -261,7 +286,7 @@ protected function _translateConditions(&$Model, &$conditions) {
* @return string
* @access protected
*/
protected function _translateOperator($Model, $operator) {
protected function _translateOperator(Model $Model, $operator) {
if (!empty($this->settings[$Model->alias]['operators'][$operator])) {
return $this->settings[$Model->alias]['operators'][$operator];
}
Expand Down
Loading