Permalink
Browse files

add more models

  • Loading branch information...
1 parent 40a9b18 commit 4ba81e70c487e78d5e67cf908732f9e977c35dcc @romaninsh romaninsh committed Oct 14, 2011
Showing with 28 additions and 0 deletions.
  1. +15 −0 lib/Model/DVD/InStore.php
  2. +13 −0 lib/Model/Movie/Available.php
View
@@ -0,0 +1,15 @@
+<?php
+class Model_DVD_InStore extends Model_DVD {
+ function init(){
+ parent::init();
+ $this->addCondition('is_rented',false);
+ }
+ function dsql_count(){
+ return $this
+ ->dsql(null,false)
+ ->field('count(*)')
+ ->where('('.$this->calculate_is_rented().')!=','Y')
+ ->where('dvd.movie_id=movie.id')
+ ;
+ }
+}
@@ -0,0 +1,13 @@
+<?php
+class Model_Movie_Available extends Model_Movie {
+ function init(){
+ parent::init();
+ $this->addCondition('available>',0);
+ }
+ function rent($customer_id){
+ $m=$this->add('Model_DVD_InStore')
+ ->loadBy('movie_id',$this->get('id'));
+
+ return $m->rent($customer_id);
+ }
+}

0 comments on commit 4ba81e7

Please sign in to comment.