Executes a SQL Query and connect the object with that query in order to operate the recordset
@param string $sql
@param string $overrideEntity
@param string[] $overrideKeys
@param string[] $overrideTypes

@return true
177957
final public function query(
        string $sql,
        string $overrideEntity = '',
        array $overrideKeys = [],
        array $overrideTypes = []
    ) {
        $this->initialize();
        if (! $this->hasDBAL()) {
            throw new \LogicException('Recordset: object does not have a connected DBAL');
        }
        $result = $this->dbal->queryResult($sql, $overrideTypes);
        if (! $result instanceof Result) {
            throw new \LogicException("Recordset: Unable to perform query $sql");
        }
        $this->mode = self::RSMODE_CONNECTED_EDIT;
        $this->result = $result;
        $this->source = $sql;
        $this->datafields = [];
        // get fields into a temporary array
        $tmpfields = $this->result()->getFields();
        $tmpfieldsCount = count($tmpfields);
        for ($i = 0; $i < $tmpfieldsCount; $i++) {
            $this->datafields[$tmpfields[$i]['name']] = $tmpfields[$i];
        }
        // set the entity name, remove if more than one table exists
        if (count(array_unique(array_column($tmpfields, 'table'))) > 1) {
            $this->entity = '';
        } else {
            $this->entity = $tmpfields[0]['table'];
        }
        if ('' !== $overrideEntity) {
            $this->entity = $overrideEntity;
        }
        // set the id fields if did not override
        if (! count($overrideKeys)) {
            $this->idFields = $this->result()->getIdFields() ?: [];
        } else {
            // validate overrideKeys
            if ($overrideKeys !== array_unique($overrideKeys)) {
                throw new \InvalidArgumentException('Keys contains repeated values');
            }
            foreach ($overrideKeys as $fieldName) {
                if (! is_string($fieldName)) {
                    throw new \InvalidArgumentException('Keys were set but at least one is not a string');
                }
                if (! array_key_exists($fieldName, $this->datafields)) {
                    throw new \InvalidArgumentException(
                        "The field name $fieldName does not exists in the set of fields"
                    );
                }
            }
            $this->idFields = $overrideKeys;
        }
        // if has records then load first
        if ($this->getRecordCount() > 0) {
            $this->moveNext();
        }
        return true;
    }
783118
public function merge($newValues, $override = true)
    {
        foreach ($newValues as $key => $value) {
            // If the key doesn't exist yet,
            // we can simply set it.
            if (!array_key_exists($key, $this)) {
                $this[$key] = $value;
                continue;
            }

            // We already know this value exists
            // so if we're in conservative mode
            // we can skip this key
            if ($override === false) {
                continue;
            }

            // Merge the values only if
            // both values are arrays
            if (is_array($this[$key]) && is_array($value)) {
                $this[$key] = array_replace_recursive($this[$key], $value);
            } else {
                $this[$key] = $value;
            }
        }
    }
399934
function query($sql, $resultmode = null)
    {
        $result = $this->tryReconnect(array($this->mysqli, 'query'), array($sql, $resultmode));
        if (!$result)
        {
            trigger_error(__CLASS__ . " SQL Error:" . $this->errorMessage($sql), E_USER_WARNING);

            return false;
        }
        if (is_bool($result))
        {
            return $result;
        }
        return new MySQLiRecord($result);
    }
1346785
public function delete_override($overrideid) {
        global $CFG, $DB;

        require_once($CFG->dirroot . '/calendar/lib.php');

        $cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course);

        $override = $DB->get_record('lesson_overrides', array('id' => $overrideid), '*', MUST_EXIST);

        // Delete the events.
        $conds = array('modulename' => 'lesson',
                'instance' => $this->properties->id);
        if (isset($override->userid)) {
            $conds['userid'] = $override->userid;
        } else {
            $conds['groupid'] = $override->groupid;
        }
        $events = $DB->get_records('event', $conds);
        foreach ($events as $event) {
            $eventold = calendar_event::load($event);
            $eventold->delete();
        }

        $DB->delete_records('lesson_overrides', array('id' => $overrideid));

        // Set the common parameters for one of the events we will be triggering.
        $params = array(
            'objectid' => $override->id,
            'context' => context_module::instance($cm->id),
            'other' => array(
                'lessonid' => $override->lessonid
            )
        );
        // Determine which override deleted event to fire.
        if (!empty($override->userid)) {
            $params['relateduserid'] = $override->userid;
            $event = \mod_lesson\event\user_override_deleted::create($params);
        } else {
            $params['other']['groupid'] = $override->groupid;
            $event = \mod_lesson\event\group_override_deleted::create($params);
        }

        // Trigger the override deleted event.
        $event->add_record_snapshot('lesson_overrides', $override);
        $event->trigger();

        return true;
    }
304376
protected function mergeColumnSchema($origin, $override)
    {
        $override->dbType .= ',' . $override->dbType;

        if ($override->isField) {
            $origin->isField = true;
        }
        if ($override->isAttribute) {
            $origin->isAttribute = true;
            $origin->type = $override->type;
            $origin->phpType = $override->phpType;

            if ($override->isMva) {
                $origin->isMva = true;
            }
        }

        return $origin;
    }
1350326
protected function compileSelectStatement($selectOverride = false)
    {
        $sqlStatement = parent::compileSelectStatement($selectOverride);

        if ($this->isSubQuery) {
            return $sqlStatement;
        }

        return str_replace('SELECT', 'SELECT SQL_CALC_FOUND_ROWS', $sqlStatement);
    }
1048158
protected static void loadPropertiesOverrides (
        PropRecord prec, Map<String,PropRecord> records, Map<String,PropRecord> applied,
        ClassLoader loader, Properties target)
        throws IOException
    {
        if (applied.containsKey(prec._package)) {
            return;
        }

        // first load up properties from all of our parent nodes
        if (prec._overrides != null) {
            for (String override : prec._overrides) {
                PropRecord parent = records.get(override);
                loadPropertiesOverrides(parent, records, applied, loader, target);
            }
        }

        // now apply our properties values
        InputStream in = prec.sourceURL.openStream();
        target.load(in);
        in.close();
        applied.put(prec._package, prec);
    }
1352119
public function haveLinkInDatabase(array $overrides = [])
    {
        $tableName = $this->grabLinksTableName();
        $defaults = Links::getDefaults();
        $overrides = array_merge($defaults, array_intersect_key($overrides, $defaults));

        return $this->haveInDatabase($tableName, $overrides);
    }
367891
protected function overrideParams($module, $override)
    {
        $params = json_decode($module->params, true);

        if (!is_array($params)) {
            $params = [];
        }

        $params = array_merge($params, $override);
        $module->params = json_encode($params);
    }
567564
def _apply_overrides(settings, overrides, schema):
    
    if overrides:
        for k, v in six.iteritems(overrides):
            if k in schema:
                if schema[k] is None:
                    settings[k] = v
                elif type(schema[k]) is dict:
                    settings[k] = _apply_overrides(settings[k], overrides[k],
                                                   schema[k])
                else:
                    raise Exception("Unexpected type found in schema '%s'" %
                                    type(schema[k]), level=ERROR)
            else:
                log("Unknown override key '%s' - ignoring" % (k), level=INFO)

    return settings
555808
public int insertOrUpdate(Connection conn, Entity record, String... keys) throws SQLException {
		final Entity where = record.filter(keys);
		if(MapUtil.isNotEmpty(where) && count(conn, where) > 0) {
			return update(conn, record, where);
		}else {
			return insert(conn, record);
		}
	}
444123
protected function merge_overrideparams(array $overrideparams = null) {
        $overrideparams = (array)$overrideparams;
        $params = $this->params;
        foreach ($overrideparams as $key => $value) {
            if (is_int($key)) {
                throw new coding_exception('Overridden parameters can not have numeric keys!');
            }
            if (is_array($value)) {
                throw new coding_exception('Overridden parameters values can not be arrays!');
            }
            if (is_object($value) and !method_exists($value, '__toString')) {
                throw new coding_exception('Overridden parameters values can not be objects, unless __toString() is defined!');
            }
            $params[$key] = (string)$value;
        }
        return $params;
    }
374454
protected function performQuery(array $configuration, &$context, array $parameters, $sql)
    {
        /** @var PDOStatement $stmt */
        $stmt = $this->getConnection($context)->executeQuery($sql, $parameters['values'], $parameters['types']);

        if ($stmt->columnCount() > 0) { // SQL query is for example a SELECT
            $result = $stmt->fetchAll();
        } else { // SQL query is for example an UPDATE
            $result = ['count' => $stmt->rowCount()];
        }

        if (array_key_exists(self::CONF_QUERY_NAME, $configuration)) {
            $name = $configuration[self::CONF_QUERY_NAME];
            $context[self::CONTEXT_RESULTS][$name] = $result;
            if (0 == count($result)) {
                throw new NoResultsException('No results found for query named: '.$name);
            }
        }

        return $result;
    }
355414
public function updateLastLogin(?Carbon $override = null)
    {
        $name = $this->getLastLoginKey();

        if ($this->getAttributeFromArray($name) === null) {
            throw new NullValueException("Property {$name} not set on this object");
        }

        $this->{$name} = $override === null ? Carbon::now()->toDateTimeString() : $override->toDateTimeString();

        $this->lastLoginParsed = null;

        return $this;
    }
1157104
private function exportToSingle(array $configurations, array $overrideData)
    {
        $configurations = array_replace_recursive($configurations, $overrideData);
        FileHelper::writeToFile($this->file, Data::toYaml($configurations));
        Schematic::info('Exported schema to '.$this->file);
    }
247423
public function setClasses($classes, $override = true)
    {
        foreach ($classes as $key => $class) {
            if ($override || !isset($this->_classes[$key])) {
                $this->_classes[$key] = $class;
            }
        }
    }
956470
public boolean hasOverride(String operation) {
        boolean result = false;

        if (this.overrideOnce.containsKey(operation) == true || this.override.containsKey(operation) == true) {
            result = true;
        }

        return result;
    }