Skip to content

Commit

Permalink
Merge pull request #26 from xmorave2/integer-read
Browse files Browse the repository at this point in the history
Adjust reading integer value in foxpro dbf
  • Loading branch information
luads committed Mar 8, 2016
2 parents 061f5b3 + aa713c8 commit ebfc1f9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/XBase/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,15 @@ public function getIndex($columnName, $length)
return false;
}

$ret = ord($s[0]);
if($this->table->foxpro) {
$su = unpack("i", $s);
$ret = $su[1];
} else {
$ret = ord($s[0]);

for ($i = 1; $i < $length; $i++) {
$ret += $i * 256 * ord($s[$i]);
for ($i = 1; $i < $length; $i++) {
$ret += $i * 256 * ord($s[$i]);
}
}

return $ret;
Expand Down

0 comments on commit ebfc1f9

Please sign in to comment.