Merge translated fields into the main records

@param Garp_Db_Table_Row $result
@return void
508435
public function mergeTranslatedFields($result) {
        if (!isset($result->{self::I18N_MODEL_BINDING_ALIAS})) {
            return;
        }
        $translationRecordList = $result->{self::I18N_MODEL_BINDING_ALIAS};
        if ($translationRecordList instanceof Zend_Db_Table_Rowset_Abstract) {
            $translationRecordList = $translationRecordList->toArray();
        }
        $translatedFields = array();
        $allLocales = Garp_I18n::getLocales();
        foreach ($this->_translatableFields as $translatableField) {
            // provide default values
            foreach ($allLocales as $locale) {
                $translatedFields[$translatableField][$locale] = null;
            }
            foreach ($translationRecordList as $translationRecord) {
                $lang = $translationRecord[self::LANG_COLUMN];
                $translatedFields[$translatableField][$lang]
                    = $translationRecord[$translatableField];
            }
            $result->setVirtual($translatableField, $translatedFields[$translatableField]);
                //$lang] = $translationRecord[$translatableField];
        }
        // We now have a $translatedFields array like this:
        // array(
        //   "name" => array(
        //     "nl" => "Schaap",
        //     "en" => "Sheep"
        //   )
        // )
        //$result->setFromArray($translatedFields);
        unset($result->{self::I18N_MODEL_BINDING_ALIAS});
    }
905391
public function result(AbstractResult $result, $row, $col)
    {
        trigger_error('Sql::result() is deprecated in favour of using the Result class, eg $result->result(0, 0)', E_USER_DEPRECATED);
        return $result->result($row, $col);
    }
174042
protected function _fetchField($result, $key = 0)
    {
        $return = null;
        if ($row = $result->fetch_row()) {
            $return = $row[(int)$key];
        }

        $result->free();

        return $return;
    }
514361
public function groupTranslations($results)
    {
        return $results->map(function ($row) {
            $translations = (array)$row['_i18n'];
            if (count($translations) === 0 && $row->get('_translations')) {
                return $row;
            }

            $result = [];
            foreach ($translations as $translation) {
                unset($translation['id']);
                $result[$translation['locale']] = $translation;
            }

            $row['_translations'] = $result;
            unset($row['_i18n']);
            if ($row instanceof EntityInterface) {
                $row->clean();
            }

            return $row;
        });
    }
1298128
protected function merge($key, $result)
    {
        if (is_null($key)) {

            // key is null, so just merge with root
            $this->config = array_merge($this->config, $result);

        } elseif (strpos($key, '.') === false) {

            // non-compound key, just merge key with incoming data
            if (!isset($this->config[$key]) && !array_key_exists($key, $this->config)) {
                throw new KeyDoesNotExistException($key);
            }

            // if $this->config[$key] is not an array, we convert it one before merging
            if (!is_array($this->config[$key])) {
                $this->config[$key] = [];
            }

            $this->config[$key] = array_merge($this->config[$key], $result);

        } else {

            // compound key, so merge with parent reference
            list($parent, $child) = $this->getParentChildKeys($key);
            $config = $this->resolveKey($parent);
            $config[$child] = array_merge($config[$child], $result);

        }
    }
86713
protected function create_recordset($result) {
        $rs = new sqlsrv_native_moodle_recordset($result, $this);
        $this->recordsets[] = $rs;
        return $rs;
    }
1370920
public function add(array $results)
    {
        $cachedResults = [];

        $keyColumn = $this->entityMap->getKeyName();

        foreach ($results as $result) {
            $id = $result[$keyColumn];

            // Forget the ID field from the cache attributes
            // to prevent any side effect.
            // TODO : remove primary key check from dirty attributes parsing
            //unset($result[$keyColumn]);
            $cachedResults[$id] = $this->rawResult($result);
        }

        if (empty($this->cache)) {
            $this->cache = $cachedResults;
        } else {
            $this->mergeCacheResults($cachedResults);
        }
    }
902722
public function makeInsertRow ($table_name, array $merge_row = [], $forced_obtain = false) {
		$merge_row += $merge_row + $this->getColumnDefaultValues($table_name, $forced_obtain);

		$not_null_columns = $this->getNotNullColumns($table_name, $forced_obtain);
		$columns = $this->getColumns($table_name, $forced_obtain);

		$auto_increment_column_list = [];
		foreach (array_keys($merge_row) as $column_name) {
			if (isset($auto_increment_column_list[$column_name])) {
				unset($merge_row[$column_name]);
			}
			if (isset($not_null_columns[$column_name]) && $merge_row[$column_name] === null) {
				$type = static::GetType($columns[$column_name]['Type']);
				switch (static::GetPdoParamList()[$type]) {
					case \PDO::PARAM_INT:
						$value = 0;
						break;
					case \PDO::PARAM_BOOL:
						$value = false;
						break;
					case \PDO::PARAM_STR:
						$value = '';
						break;
					case \PDO::PARAM_LOB:
						$value = 0;
						break;
					default:
						$value = '';
						break;
				}
				$merge_row[$column_name] = $value;
			}
		}
		ksort($merge_row);
		return $merge_row;
	}
1364771
protected function handleResult(array $result)
    {
        if ($this->onlyCount && isset($result[0]) && is_array($result[0])) {
            return (int)current($result[0]);
        }

        $entities = [];
        foreach ($result as $row) {
            $model = clone $this->getModel();
            $model->populate($row);
            $entities[] = $model;
        }
        return $entities;
    }
339795
abstract function __construct($result, $buffered = true);

	/**
	 * Unserialize the SQLResultSet.
	 *
	 * @param string $data
	 *
	 * @return void
	 */

	public function unserialize($data){

		$this->_fetched = unserialize($data);
	}
350116
public function join_result($result, $key, $newres) {
        if (isset($result['regrinfo'][$key]) && !array_key_exists(0, $result['regrinfo'][$key])) {
            $r = $result['regrinfo'][$key];
            $result['regrinfo'][$key] = array($r);
        }

        $result['regrinfo'][$key][] = $newres['regrinfo'][$key];
        return $result;
    }
120962
public function processColumnListing($results)
    {
        return array_values(array_map(function ($result)
        {
            $result = (object) $result;

            return $result->name;

        }, $results));
    }
1325973
protected function processPlayer($data, $fieldCount, Result &$result)
    {

        // Split the items on the comma
        $items = explode(",", $data, $fieldCount);

        // Iterate over the items for this player
        foreach ($items as $item) {
            // Split the key=value pair
            list($key, $value) = explode("=", $item, 2);

            $result->addPlayer(strtolower($key), utf8_encode($value));
        }
    }
295430
public function fetchAssoc($result = null)
    {
        $result = $result ? $result : $this->getResult();

        $rows = [];

        if ($result->rowCount() > 0) {
            $results = $result->fetchAll(\PDO::FETCH_ASSOC);
            foreach ($results as $key => $value) {
                $rows[$key] = $value;
            }
        }

        return $rows;
    }
855406
public function addResult($result, $value)
    {
        if (! $this->open) {
            return;
        }
        
        if ($value !== null) {
            $this->results[$result] = $value;
        }
    }
864078
protected static function parseString(&$data, &$result)
    {
        // Character string type
        $data = self::parseCommon($data, $stringData);
        $result[] = [
            'string (' . self::$len . ')',
            $stringData, ];
    }
807181
public function dataSeek($result_object,$rownum,$which_connection='')
    {
        if ($which_connection == '') {
            $which_connection = $this->default_db;
        }

        return $result_object->Move((int)$rownum);
    }