db ->table(self::TABLE) ->columns( self::TABLE.'.id', self::TABLE.'.subtask_id', self::TABLE.'.end', self::TABLE.'.start', SubTask::TABLE.'.task_id', SubTask::TABLE.'.title AS subtask_title', Task::TABLE.'.title AS task_title', Task::TABLE.'.project_id' ) ->join(SubTask::TABLE, 'id', 'subtask_id') ->join(Task::TABLE, 'id', 'task_id', SubTask::TABLE) ->eq(self::TABLE.'.user_id', $user_id); } /** * Log start time * * @access public * @param integer $subtask_id * @param integer $user_id * @return boolean */ public function logStartTime($subtask_id, $user_id) { return $this->db ->table(self::TABLE) ->insert(array('subtask_id' => $subtask_id, 'user_id' => $user_id, 'start' => time())); } /** * Log end time * * @access public * @param integer $subtask_id * @param integer $user_id * @return boolean */ public function logEndTime($subtask_id, $user_id) { return $this->db ->table(self::TABLE) ->eq('subtask_id', $subtask_id) ->eq('user_id', $user_id) ->eq('end', 0) ->update(array( 'end' => time() )); } }