/** * transformData * * Split data into an array prefixed with field names. * * @access private * @param string $data * @param Projection $projection * @return array */ private function transformData($data, Projection $projection) { $values = str_getcsv($data); $definition = $projection->getFieldNames(); $out_values = []; $values_count = count($values); for ($index = 0; $index < $values_count; $index++) { $out_values[$definition[$index]] = preg_match(':^{.*}$:', $values[$index]) ? stripcslashes($values[$index]) : $values[$index]; } return $out_values; }
/** * convertSlice * * Convert a slice. * * @access protected * @param array $values * @param string $name * @return array */ protected function convertSlice(array $values, $name) { $type = $this->projection->getFieldType($name); $converter = $this->hydration_plan->getConverterForField($name); return array_map(function ($val) use($converter, $type) { return $converter->fromPg($val, $type, $this->session); }, $values); }
/** * getFindWhereSql * * This is the standard SQL query to fetch instances from the current * relation. * * @access protected * @param Where $where * @param Projection $projection * @param string $suffix * @return string */ protected function getFindWhereSql(Where $where, Projection $projection, $suffix = '') { return strtr('select :projection from :relation where :condition :suffix', [':projection' => $projection->formatFieldsWithFieldAlias(), ':relation' => $this->getStructure()->getRelation(), ':condition' => (string) $where, ':suffix' => $suffix]); }