Use an alias for max(id) fetch

master
Loic Blot 2015-11-21 18:01:06 +01:00
parent b532f79fac
commit 8aaba8512b
1 changed files with 2 additions and 2 deletions

View File

@ -56,13 +56,13 @@ class CityMapper extends Mapper {
$query->execute(array($userId, $name)); $query->execute(array($userId, $name));
\OCP\DB::commit(); \OCP\DB::commit();
$sql = 'SELECT max(id) FROM ' . $sql = 'SELECT max(id) as maxid FROM ' .
'*PREFIX*weather_city WHERE user_id = ? and name = ?'; '*PREFIX*weather_city WHERE user_id = ? and name = ?';
$query = \OCP\DB::prepare($sql); $query = \OCP\DB::prepare($sql);
$result = $query->execute(array($userId, $name)); $result = $query->execute(array($userId, $name));
if ($row = $result->fetchRow()) { if ($row = $result->fetchRow()) {
return $row['max']; return $row['maxid'];
} }
return null; return null;
} }