-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschemaless.php
More file actions
executable file
·89 lines (83 loc) · 1.93 KB
/
schemaless.php
File metadata and controls
executable file
·89 lines (83 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* Schemaless behavior.
*
* Adds functionality specific to MongoDB/schemaless dbs
* Allow /not/ specifying the model's schema, and derive it (for cake-compatibility) from the data
* being saved. Note that used carelessly this is a pretty dangerous thing to allow - means a user
* can modify input forms adding whatever fields they like (unless you'er using the security
* component) and fill your db with their junk.
*
* PHP version 5
*
* Copyright (c) 2010, Andy Dawson
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2010, Andy Dawson
* @link www.ad7six.com
* @package mongodb
* @subpackage mongodb.models.behaviors
* @since v 1.0 (24-May-2010)
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* SchemalessBehavior class
*
* @uses ModelBehavior
* @package mongodb
* @subpackage mongodb.models.behaviors
*/
class SchemalessBehavior extends ModelBehavior {
/**
* name property
*
* @var string 'Schemaless'
* @access public
*/
public $name = 'Schemaless';
/**
* settings property
*
* @var array
* @access public
*/
public $settings = array();
/**
* defaultSettings property
*
* @var array
* @access protected
*/
protected $_defaultSettings = array(
);
/**
* setup method
*
* Don't currently have any settings at all - disabled
*
* @param mixed $Model
* @param array $config array()
* @return void
* @access public
*/
public function setup(&$Model, $config = array()) {
//$this->settings[$Model->alias] = array_merge($this->_defaultSettings, $config);
}
/**
* beforeSave method
*
* Set the schema to allow saving whatever has been passed
*
* @param mixed $Model
* @return void
* @access public
*/
public function beforeSave(&$Model) {
$Model->cacheSources = false;
$Model->schema(true);
return true;
}
}