Пример #1
0
 /**
  * read
  *
  * @param string|int $id
  *
  * @return  string
  */
 public function read($id)
 {
     // Get the session data from the database table.
     $query = $this->db->getQuery(true);
     $query->select($this->db->quoteName($this->options['data_col']))->from($this->db->quoteName($this->options['table']))->where($this->db->quoteName($this->options['id_col']) . ' = ' . $this->db->quote($id));
     $this->db->setQuery($query);
     return (string) $this->db->loadResult();
 }
Пример #2
0
 /**
  * Read the data for a particular session identifier from the SessionHandler backend.
  *
  * @param   string  $id  The session identifier.
  *
  * @return  string  The session data.
  *
  * @since   1.0
  */
 public function read($id)
 {
     try {
         // Get the session data from the database table.
         $query = $this->db->getQuery(true);
         $query->select($this->db->quoteName('data'))->from($this->db->quoteName('#__session'))->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id));
         $this->db->setQuery($query);
         return (string) $this->db->loadResult();
     } catch (\Exception $e) {
         return false;
     }
 }
Пример #3
0
 /**
  * Process labels for adding into the issues table
  *
  * @param   integer  $issueId  Issue ID to process
  *
  * @return  array
  *
  * @since   1.0
  */
 protected function processLabels($issueId)
 {
     try {
         $githubLabels = $this->github->issues->get($this->project->gh_user, $this->project->gh_project, $issueId)->labels;
     } catch (\DomainException $exception) {
         $this->logger->error(sprintf('Error parsing the labels for GitHub issue %s/%s #%d - %s', $this->project->gh_user, $this->project->gh_project, $issueId, $exception->getMessage()));
         return '';
     }
     $appLabelIds = array();
     // Make sure the label is present in the database by pulling the ID, add it if it isn't
     $query = $this->db->getQuery(true);
     foreach ($githubLabels as $label) {
         $query->clear()->select($this->db->quoteName('label_id'))->from($this->db->quoteName('#__tracker_labels'))->where($this->db->quoteName('project_id') . ' = ' . (int) $this->project->project_id)->where($this->db->quoteName('name') . ' = ' . $this->db->quote($label->name));
         $this->db->setQuery($query);
         $id = $this->db->loadResult();
         // If null, add the label
         if ($id === null) {
             $table = new LabelsTable($this->db);
             $data = array();
             $data['project_id'] = $this->project->project_id;
             $data['name'] = $label->name;
             $data['color'] = $label->color;
             try {
                 $table->save($data);
                 $id = $table->label_id;
             } catch (\RuntimeException $exception) {
                 $this->logger->error(sprintf('Error adding label %s for project %s/%s to the database: %s', $label->name, $this->project->gh_user, $this->project->gh_project, $exception->getMessage()));
             }
         }
         // Add the ID to the array
         $appLabelIds[] = $id;
     }
     return $appLabelIds;
 }
 /**
  * Validate that the primary key has been set.
  *
  * @return  boolean  True if the primary key(s) have been set.
  *
  * @since   1.0
  */
 public function hasPrimaryKey()
 {
     if ($this->autoIncrement) {
         $empty = true;
         foreach ($this->tableKeys as $key) {
             $empty = $empty && !$this->{$key};
         }
     } else {
         $query = $this->db->getQuery(true)->select('COUNT(*)')->from($this->tableName);
         $this->appendPrimaryKeys($query);
         $this->db->setQuery($query);
         $count = $this->db->loadResult();
         if ($count == 1) {
             $empty = false;
         } else {
             $empty = true;
         }
     }
     return !$empty;
 }