Skip to content

Commit

Permalink
fixup! use proper types in API (fossar#879)
Browse files Browse the repository at this point in the history
  • Loading branch information
niol committed Jun 22, 2017
1 parent b1d4321 commit 9c04f8c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 5 additions & 1 deletion daos/mysql/Statements.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@ public function ensureRowTypes(array $rows, array $expectedRowTypes) {
case \daos\PARAM_CSV:
$value = explode(',', $row[$columnIndex]);
break;
default:
$value = null;
}
if ($value !== null) {
$rows[$rowIndex][$columnIndex] = $value;
}
$rows[$rowIndex][$columnIndex] = $value;
}
}
}
Expand Down
20 changes: 19 additions & 1 deletion daos/pgsql/Statements.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ public static function csvRowMatches($column, $value) {
* expected types
*/
public function ensureRowTypes(array $rows, array $expectedRowTypes) {
return $rows; // pgsql returns correct PHP types
foreach ($rows as $rowIndex => $row) {
foreach ($expectedRowTypes as $columnIndex => $type) {
if (array_key_exists($columnIndex, $row)) {
switch ($type) {
// pgsql returns correct PHP types for INT and BOOL
case \daos\PARAM_CSV:
$value = explode(',', $row[$columnIndex]);
break;
default:
$value = null;
}
if ($value !== null) {
$rows[$rowIndex][$columnIndex] = $value;
}
}
}
}

return $rows;
}
}

0 comments on commit 9c04f8c

Please sign in to comment.