Back to ChangeItem class

Method check

public int
check
()
Runs the check query and checks that 1 row is returned
Returns
  • int 1 if success, -1 if skipped, -2 if check failed
Since
  • 2.5
Class: ChangeItem
Project: Joomla

Method check - Source code

/**
 * Runs the check query and checks that 1 row is returned
 *
 * @return  integer  1 if success, -1 if skipped, -2 if check failed
 *
 * @since  2.5
 */
public function check()
{
    $this->checkStatus = -1;
    if ($this->checkQuery) {
        try {
            $this->db->setQuery($this->checkQuery);
            $rows = $this->db->loadRowList(0);
        } catch (\RuntimeException $e) {
            // Still render the error message from the Exception object
            Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
            $this->checkStatus = -2;
            return $this->checkStatus;
        }
        if (\count($rows) === $this->checkQueryExpected) {
            $this->checkStatus = 1;
            return $this->checkStatus;
        }
        $this->checkStatus = -2;
    }
    return $this->checkStatus;
}