Skip to content

Commit

Permalink
Merge pull request #184 from cyklokoalicia/bug_fix2
Browse files Browse the repository at this point in the history
Fix bike rent
  • Loading branch information
sveneld authored Mar 16, 2024
2 parents 2316f7e + 7f2653c commit 64fcc67
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
10 changes: 5 additions & 5 deletions actions-web.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,13 @@ function userbikes($userId)
$bicycles[] = $bikenum;
$codes[] = str_pad($row['currentCode'], 4, '0', STR_PAD_LEFT);
// get rented seconds and the old code
$result2 = $db->query("SELECT TIMESTAMPDIFF(SECOND, time, NOW()), parameter FROM history WHERE bikeNum=$bikenum AND action IN ('RENT','FORCERENT') ORDER BY time DESC LIMIT 2");
$result2 = $db->query("SELECT TIMESTAMPDIFF(SECOND, time, NOW()) as rentedSeconds, parameter FROM history WHERE bikeNum=$bikenum AND action IN ('RENT','FORCERENT') ORDER BY time DESC LIMIT 2");

$row2 = $result2->fetch_row();
$rentedseconds[] = $row2[0];
$row2 = $result2->fetchAssoc();
$rentedseconds[] = $row2['rentedSeconds'];

$row2 = $result2->fetch_row();
$oldcodes[] = str_pad($row2[1], 4, '0', STR_PAD_LEFT);
$row2 = $result2->fetchAssoc();
$oldcodes[] = str_pad($row2['parameter'], 4, '0', STR_PAD_LEFT);
}

if (!$result->num_rows) {
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ services:
- PMA_HOST=db
- PMA_USER=root
- PMA_PASSWORD=password
- UPLOAD_LIMIT=30M
15 changes: 15 additions & 0 deletions src/Db/MysqliDbResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ public function rowCount()
return $this->result ? (int)$this->result->num_rows : 0;
}

/**
* @TODO temporary solution, should be removed
*/
public function __call($name, $arguments)
{
if (method_exists($this->result, $name)) {
return call_user_func_array([$this->result, $name], $arguments);
} else {
throw new \Exception("Method $name not found");
}
}

/**
* @TODO temporary solution, should be removed
*/
public function __get($name)
{
if ($name === 'num_rows') {
Expand Down

0 comments on commit 64fcc67

Please sign in to comment.