summaryrefslogtreecommitdiffstats
path: root/models/Entry.php
diff options
context:
space:
mode:
authorraylu <raylu@mixpanel.com>2011-07-02 17:02:07 -0700
committerraylu <raylu@mixpanel.com>2011-07-02 17:02:07 -0700
commit05a2b26d9038752a40348a3f226e44710833c49b (patch)
tree9bc3e49ac2e84b33ca5ff6e44eb7e5f2c02d13bf /models/Entry.php
parent83483a1826d1d05e2f9733746f35fef1939b8c0a (diff)
downloadotakuhub-05a2b26d9038752a40348a3f226e44710833c49b.tar.xz
pull in dev branch changes
not pulled: swiftmailer, gzip
Diffstat (limited to 'models/Entry.php')
-rw-r--r--models/Entry.php26
1 files changed, 14 insertions, 12 deletions
diff --git a/models/Entry.php b/models/Entry.php
index e84d438..12a3035 100644
--- a/models/Entry.php
+++ b/models/Entry.php
@@ -10,9 +10,9 @@ Class entry extends \lithium\data\Model {
public static function __init() {
parent::__init();
- //Validators go here
}
+ public $_schema = array('_id' => array('type' => 'id'));
public $validates = array(
'my_watched_episodes' => array('numeric', 'message' => 'please enter a number'),
'my_start_date' => array('date', 'message' => 'Please enter a valid date'),
@@ -20,7 +20,7 @@ Class entry extends \lithium\data\Model {
'my_score' => array(array('inRange' => array('min' => 0, 'max' => '10'), 'message' => 'Enter a valid score'),
array('numeric', 'message' => 'Please enter a number')),
//'my_status' => array('isValidStatus', 'message' => 'please enter valid status'),
- 'my_times_watched' => array('numeric', 'message' => 'This must be a number')
+ 'my_times_watched' => array('numeric', 'message' => 'This must be a number'),
);
//Add timestamping to entries. :TODO:
@@ -29,36 +29,38 @@ Class entry extends \lithium\data\Model {
- /*
public function add($entity, $username)
{
- var_dump($entity->_data);
- exit();
- $updateData = array('$push' => array('animelist' => $entity));
- $conditions = array('username' => $username);
+ $updateData = array('$push' => array('animelist' => $entity->data()));
+ $conditions = compact('username');
$result = Entry::update($updateData, $conditions, array('atomic' => false));
return $result;
}
- */
+ /*
//Got lazy, the proper way to do it is above, but needs a bit of fiddling.
- //The below code works, but forces mongo to resave the entire record, which tags
+ //The below code works, but forces mongo to resave the entire record, which takes
//longer than just updating what has chaged.
public function add($entity, $username)
{
$user = User::find('first', array('conditions' => compact('username')));
$entity->created_on = new MongoDate();
$entity->updated_on = new MongoDate();
+
$user->animelist[] = $entity;
- if (Validator::check($entity->data(), $this->validates, array('skipEmpty' => 'true'))) {
- return $user->save(null, array('validate' => false));
- }
+ //if (Validator::check($entity->data(), $this->validates, array('skipEmpty' => 'true'))) {
+ $return = $user->save(null, array('validate' => false));
+ var_dump($entity);
+ exit();
+ /*
else
{
return false;
}
+
}
+ */
public function edit($entity, $username)
{