Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Helper: Provides that only meant database fields are changed.
- *
- * @param array $fields Fields (key, value pairs)
- * @param array $expected Changeable fields (just keys)
- * @throws HTTP_Exception_400 If any key of 1st array is not found in 2nd array, but is table column
- */
- function check_fields($fields, $changeable) {
- $field_keys = array_keys($fields);
- $column_keys = array_keys($this->_data);
- foreach ($field_keys as $key) {
- if (is_array($fields[$key])) {
- $this->check_fields($fields[$key], $changeable[$key]);
- }
- if (!in_array($key, $changeable) && in_array($key, $column_keys)) {
- throw new HTTP_Exception_400("Trying to change database fields that aren't meant to be changed!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement