Proyectos de Subversion LeadersLinked - Services

Rev

Rev 283 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 283 Rev 302
Línea 51... Línea 51...
51
     * @param int $company_id
51
     * @param int $company_id
52
     * @param int $topic_id
52
     * @param int $topic_id
53
     * @param int $capsule_id
53
     * @param int $capsule_id
54
     * return int
54
     * return int
55
     */
55
     */
56
    public function fetchCountByCompanyIdAndTopicIdAndCapsuleId($company_id, $topic_id, $capsule_id)
56
    public function fetchCountByCompanyIdAndCapsuleId($company_id, $capsule_id)
57
    {
57
    {
Línea 58... Línea 58...
58
 
58
 
59
        $select = $this->sql->select();
59
        $select = $this->sql->select();
60
        $select->columns(['total' => new Expression('COUNT(*)')]);
60
        $select->columns(['total' => new Expression('COUNT(*)')]);
61
        $select->from(self::_TABLE);
61
        $select->from(self::_TABLE);
62
        $select->where->equalTo('company_id', $company_id);
-
 
63
        $select->where->equalTo('topic_id', $topic_id);
62
        $select->where->equalTo('company_id', $company_id);
Línea 64... Línea 63...
64
        $select->where->equalTo('capsule_id', $capsule_id);
63
        $select->where->equalTo('capsule_id', $capsule_id);
65
        
64
        
66
        $record = $this->executeFetchOneArray($select);
65
        $record = $this->executeFetchOneArray($select);
Línea 67... Línea -...
67
        return $record['total'];
-
 
68
    }
-
 
69
 
-
 
Línea 70... Línea -...
70
    
-
 
71
 
-
 
72
    
-
 
73
 
-
 
74
    /**
-
 
75
     *
-
 
76
     * @param int $company_id
-
 
77
     * @param int $topic_id
-
 
78
     * @param int $capsule_id
-
 
79
     * return MicrolearningCapsuleComment[]
-
 
80
     */
-
 
81
    public function fetchAllByCompanyIdAndTopicIdAndCapsuleId($company_id, $topic_id, $capsule_id)
-
 
82
    {
-
 
83
        $prototype = new MicrolearningCapsuleComment();
-
 
84
        
-
 
85
        $select = $this->sql->select();
-
 
86
        $select->from(self::_TABLE);
-
 
87
        $select->where->equalTo('company_id', $company_id);
-
 
88
        $select->where->equalTo('topic_id', $topic_id);
-
 
Línea 89... Línea 66...
89
        $select->where->equalTo('capsule_id', $capsule_id);
66
        return $record['total'];
90
        
67
    }
Línea 91... Línea 68...
91
        return $this->executeFetchAllObject($select, $prototype);
68
 
Línea 129... Línea 106...
129
   
106
   
130
   
107
   
131
   /**
108
   /**
132
    *
-
 
133
    * @param int $company_id
109
    *
134
    * @param int $topic_id
110
    * @param int $company_id
135
    * @param int $capsule_id
111
    * @param int $capsule_id
136
    * @param string $search
112
    * @param string $search
137
    * @param int $page
113
    * @param int $page
138
    * @param int $records_per_page
114
    * @param int $records_per_page
139
    * @param string $order_field
115
    * @param string $order_field
140
    * @param string $order_direction
116
    * @param string $order_direction
141
    * @return Paginator
117
    * @return Paginator
142
    */
118
    */
143
   public function fetchAllDataTableByCompanyIdAndTopicId($company_id, $topic_id, $capsule_id, $search, $page = 1, $records_per_page = 10, $order_field= 'name', $order_direction = 'ASC')
119
   public function fetchAllDataTableByCompanyIdAndCapsuleId($company_id, $capsule_id, $search, $page = 1, $records_per_page = 10, $order_field= 'name', $order_direction = 'ASC')
144
   {
120
   {
145
       $prototype = new MicrolearningCapsuleComment();
121
       $prototype = new MicrolearningCapsuleComment();
146
       $select = $this->sql->select(self::_TABLE);
-
 
147
       $select->where->equalTo('company_id', $company_id);
122
       $select = $this->sql->select(self::_TABLE);
Línea 148... Línea 123...
148
       $select->where->equalTo('topic_id', $topic_id);
123
       $select->where->equalTo('company_id', $company_id);
149
       $select->where->equalTo('capsule_id', $capsule_id);
124
       $select->where->equalTo('capsule_id', $capsule_id);
150
       
125
       
Línea 168... Línea 143...
168
   }
143
   }
Línea 169... Línea 144...
169
   
144
   
170
   /**
145
   /**
171
    * 
146
    * 
172
    * @param int $company_id
-
 
173
    * @param int $topic_id
147
    * @param int $company_id
174
    * @param int $capsule_id
148
    * @param int $capsule_id
175
    * @param int $user_id
149
    * @param int $user_id
176
    * @return void|MicrolearningCapsuleComment
150
    * @return void|MicrolearningCapsuleComment
177
    */
151
    */
178
   public function fetchOneByCompanyIdAndTopicIdAndCapsuleIdAndUserId($company_id, $topic_id, $capsule_id, $user_id)
152
   public function fetchOneByCompanyIdAndCapsuleIdAndUserId($company_id, $capsule_id, $user_id)
179
   {
153
   {
180
       $select = $this->sql->select();
154
       $select = $this->sql->select();
181
       $select->from(self::_TABLE);
155
       $select->from(self::_TABLE);
182
       $select->where->equalTo('company_id', $company_id);
-
 
183
       $select->where->equalTo('topic_id', $topic_id);
156
       $select->where->equalTo('company_id', $company_id);
184
       $select->where->equalTo('capsule_id', $capsule_id);
157
       $select->where->equalTo('capsule_id', $capsule_id);
Línea 185... Línea 158...
185
       $select->where->equalTo('user_id', $user_id);
158
       $select->where->equalTo('user_id', $user_id);
186
       
159
       
Línea 193... Línea 166...
193
    * @param int $company_id
166
    * @param int $company_id
194
    * @param int $topic_id
167
    * @param int $topic_id
195
    * @param int $capsule_id
168
    * @param int $capsule_id
196
    * @return number[]
169
    * @return number[]
197
    */
170
    */
198
   public function fetchCountAndRatingAverage($company_id, $topic_id, $capsule_id)
171
   public function fetchCountAndRatingAverage($company_id, $capsule_id)
199
   {
172
   {
200
       $select = $this->sql->select();
173
       $select = $this->sql->select();
201
       $select->columns([
174
       $select->columns([
202
           'total_comments' => new Expression('COUNT(*)'), 
175
           'total_comments' => new Expression('COUNT(*)'), 
203
           'total_rating'   => new Expression('COALESCE(AVG(rating), 0)')
176
           'total_rating'   => new Expression('COALESCE(AVG(rating), 0)')
204
       ]);
177
       ]);
Línea 205... Línea 178...
205
 
178
 
206
       $select->from(self::_TABLE);
179
       $select->from(self::_TABLE);
207
       $select->where->equalTo('company_id', $company_id);
-
 
208
       $select->where->equalTo('topic_id', $topic_id);
180
       $select->where->equalTo('company_id', $company_id);
Línea 209... Línea 181...
209
       $select->where->equalTo('capsule_id', $capsule_id);
181
       $select->where->equalTo('capsule_id', $capsule_id);
Línea 210... Línea 182...
210
    
182