Check for any mysql errors.
772817
public function throwErrorIfNoRowsAffected($sqlStatement, $ignoreDuplicate = false)
    {
        if (! $this->hasFetchedRows($sqlStatement)) {
            $error = print_r($sqlStatement->errorInfo(), true);

            if ($ignoreDuplicate and preg_match('/duplicate/i', $error)) {
                return $sqlStatement->errorInfo();
            }

            throw new \Exception(
                sprintf(
                    'No rows were effected!%sSQL: "%s",%sError: %s',
                    PHP_EOL,
                    $sqlStatement->queryString,
                    PHP_EOL,
                    $error
                )
            );
        }

        return false;
    }
437142
def handle_integrity_error(cls, exception):
        """"""

        m = re.match(cls.MYSQL_INSERT_ERROR_REGEX,
                     exception.statement)

        if not m:
            raise exception

        model = find_model_by_table_name(m.group('table'))

        if not model:
            raise exception

        m = re.match(cls.MYSQL_DUPLICATE_ENTRY_ERROR_REGEX,
                     exception.orig.args[1])

        if not m:
            raise exception

        entity = model.__name__
        eid = m.group('value')

        raise AlreadyExistsError(entity=entity, eid=eid)
405907
def handle_flush_error(cls, exception):
        """"""

        trace = exception.args[0]
        m = re.match(cls.MYSQL_FLUSH_ERROR_REGEX, trace)

        if not m:
            raise exception

        entity = m.group('entity')
        eid = m.group('eid')

        raise AlreadyExistsError(entity=entity, eid=eid)
573263
def _CheckPacketSize(cursor):
  """"""
  cur_packet_size = int(_ReadVariable("max_allowed_packet", cursor))
  if cur_packet_size < MAX_PACKET_SIZE:
    raise Error(
        "MySQL max_allowed_packet of {0} is required, got {1}. "
        "Please set max_allowed_packet={0} in your MySQL config.".format(
            MAX_PACKET_SIZE, cur_packet_size))
455483
private function checkMysqlConnection() {
        $this->connection = new \mysqli(
            $this->config->get('backup::config')['BACKUP_MYSQL_HOST'],
            $this->config->get('backup::config')['BACKUP_MYSQL_USER'],
            $this->config->get('backup::config')['BACKUP_MYSQL_PASSWORD']);

        if ($this->connection->connect_errno) {
            $this->event->fire('MonasheeBackupError', 'No database connection');

            throw new \Exception('Error connecting to MySQL');
        }

        echo 'Connected: '.$this->connection->host_info."\n";
        echo 'Server info: '.$this->connection->get_server_info()."\n";

        return true;
    }
1098423
protected function _mysql()
	{
		$this->_msg(sprintf('Adding label and status columns'), 0);
		$this->_status( '' );

		foreach ($this->_mysql as $table => $columns) {

			if ($this->_schema->tableExists($table)) {

				foreach ($columns as $column => $stmt) {

					$this->_msg(sprintf('Checking column "%1$s.%2$s": ', $table, $column), 1);

					if (!$this->_schema->columnExists($table, $column)) {
						$this->_execute($stmt);
						$this->_status('added');
					} else {
						$this->_status('OK');
					}
				}
			}
		}
	}
101501
def run_checks
      # check that mysql tmpdir is custom setup on all servers
      query = "show variables like 'tmpdir'"
      query_command = "echo -e \"#{query}\"| mysql"
      @servers.each do |server|
        server.spot_check(query_command) { |result| raise "Failure: tmpdir was unset#{result}" unless result.include?("/mnt/mysqltmp") }
      end
    end
15642
function Error($err,$fn)
	{
	global $_ADODB_ACTIVE_DBS;

		$fn = get_class($this).'::'.$fn;
		$this->_lasterr = $fn.': '.$err;

		if ($this->_dbat < 0) {
			$db = false;
		}
		else {
			$activedb = $_ADODB_ACTIVE_DBS[$this->_dbat];
			$db = $activedb->db;
		}

		if (function_exists('adodb_throw')) {
			if (!$db) {
				adodb_throw('ADOdb_Active_Record', $fn, -1, $err, 0, 0, false);
			}
			else {
				adodb_throw($db->databaseType, $fn, -1, $err, 0, 0, $db);
			}
		} else {
			if (!$db || $db->debug) {
				ADOConnection::outp($this->_lasterr);
			}
		}

	}
301423
public function hasError(): bool
    {
        foreach ($this->getResultSets() as $resultSet) {
            if ($resultSet->getResponse()->hasError()) {
                return true;
            }
        }

        return false;
    }
669651
public function check() {
        $field = null;
        $this->_errors = [];
        $fields = $this->_getField();

        foreach ($this->_constraints as $constraints) {
            /** @var \Gcs\Framework\Core\Orm\Entity\Type\File $value */
            foreach ($fields as $value) {
                if ($value != null) {
                    switch ($constraints['type']) {
                        case self::ACCEPT:
                            if (!in_array($value->contentType, $constraints['value'])) {
                                array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                            }
                            break;

                        case self::EXTENSION:
                            if (!in_array($value->extension(), $constraints['value'])) {
                                array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                            }
                            break;

                        case self::SIZE:
                            if (strlen($value->content) != $constraints['value']) {
                                array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                            }
                            break;

                        case self::SIZEMIN:
                            if (strlen($value->content) < $constraints['value']) {
                                array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                            }
                            break;

                        case self::SIZEMAX:
                            if (strlen($value->content) > $constraints['value']) {
                                array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                            }
                            break;

                        case self::SIZEBETWEEN:
                            if (!in_array(strlen($value->content), $constraints['value'])) {
                                array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                            }
                            break;
                    }
                }
                else {
                    array_push($this->_errors, ['field' => $this->_label, 'message' => $constraints['message']]);
                }
            }
        }
    }
23877
def _CheckConnectionEncoding(cursor):
  """"""
  cur_character_set = _ReadVariable("character_set_connection", cursor)
  if cur_character_set != CHARACTER_SET:
    raise EncodingEnforcementError(
        "Require MySQL character_set_connection of {}, got {}.".format(
            CHARACTER_SET, cur_character_set))
364923
def check_query(query):
    
    q = query.lower()
    if "select " not in q:
        raise InvalidQuery("SELECT word not found in the query: {0}".format(query))
    if " from " not in q:
        raise InvalidQuery("FROM word not found in the query: {0}".format(query))
485312
static function check() {
		try {
			if (error_get_last() && self::isFatal()) {
				self::i()->log();
			}
		}
		catch (\Exception $e) {
			df_log(df_ets($e));
		}
	}
1265974
def _CheckCollation(cursor):
  """"""

  # Do not fail for wrong collation, because changing it is harder than changing
  # the character set. Some providers only allow changing character set and then
  # use the default collation. Also, misconfigured collation is not expected to
  # have major negative impacts, since it only affects string sort order for
  # some locales.

  cur_collation_connection = _ReadVariable("collation_connection", cursor)
  if cur_collation_connection != COLLATION:
    logging.warning("Require MySQL collation_connection of %s, got %s.",
                    COLLATION, cur_collation_connection)

  cur_collation_database = _ReadVariable("collation_database", cursor)
  if cur_collation_database != COLLATION:
    logging.warning(
        "Require MySQL collation_database of %s, got %s."
        " To create your database, use: %s", COLLATION, cur_collation_database,
        CREATE_DATABASE_QUERY)
819459
private static function CheckConditions(){
            $oThis = self::CreateInstanceIfNotExists();
            $oThis->sBuffer = str_replace("{else}", "<?php } else { ?>", $oThis->sBuffer);
            $oThis->sBuffer = str_replace("{endif}", "<?php } ?>", $oThis->sBuffer);
            $oThis->sBuffer = str_replace(array('{if }', '{if  }'), "<?php if(false){ ?>", $oThis->sBuffer);

            //IF
            $Offset = 0;

            while(preg_match('/{if\s*(.*?)}/i', $oThis->sBuffer, $aMatches, PREG_OFFSET_CAPTURE, $Offset)){
                $oThis->sBuffer = str_replace($aMatches[0][0], "<?php if(".$aMatches[1][0]."){ ?>", $oThis->sBuffer);
                $Offset = $aMatches[0][1]+strlen($aMatches[0][0]);
            }

            //Elseif
            $Offset = 0;

            while(preg_match('/{elseif\s*(.*?)}/i', $oThis->sBuffer, $aMatches, PREG_OFFSET_CAPTURE, $Offset)){
                $oThis->sBuffer = str_replace($aMatches[0][0], "<?php } elseif(".$aMatches[1][0]."){ ?>", $oThis->sBuffer);
                $Offset = $aMatches[0][1]+strlen($aMatches[0][0]);
            }
        }
102130
public function diagnose() {
        $sloppymyisamfound = false;
        $prefix = str_replace('_', '\\_', $this->prefix);
        $sql = "SELECT COUNT('x')
                  FROM INFORMATION_SCHEMA.TABLES
                 WHERE table_schema = DATABASE()
                       AND table_name LIKE BINARY '$prefix%'
                       AND Engine = 'MyISAM'";
        $this->query_start($sql, null, SQL_QUERY_AUX);
        $result = $this->mysqli->query($sql);
        $this->query_end($result);
        if ($result) {
            if ($arr = $result->fetch_assoc()) {
                $count = reset($arr);
                if ($count) {
                    $sloppymyisamfound = true;
                }
            }
            $result->close();
        }

        if ($sloppymyisamfound) {
            return get_string('myisamproblem', 'error');
        } else {
            return null;
        }
    }
1223373
private function checkValidity()
    {

        if (!is_writable($this->rssFile)) {
            $this->valid = false;
            return;
        }

        $stmt = $this->db->prepare('SELECT CREATED FROM ' . $this->table . ' ORDER BY CREATED DESC LIMIT 1');
        $stmt->execute();
        $res = $stmt->fetchAll();

        if (count($res) == 0) {
            $this->valid = false;
            return;
        }

        $latestInput = strtotime($res[0]->CREATED);

        $rssCreated = filemtime($this->rssFile);

        if ($latestInput > $rssCreated) {
            $this->valid = false;
        } else {
            $this->valid = true;
        }
    }