Various fixes and cleanup :
* Always return at least success information * Fix issues with Wishes * Fix issues with Circulations * Fix typos in exceptions
This commit is contained in:
@@ -64,6 +64,7 @@ class OdbcResultSet implements \Iterator, \ArrayAccess
|
||||
private $results;
|
||||
private $error;
|
||||
private $num_fields;
|
||||
private $num_rows;
|
||||
private $cursor_index;
|
||||
|
||||
public function __construct($odbc_result)
|
||||
@@ -74,6 +75,7 @@ class OdbcResultSet implements \Iterator, \ArrayAccess
|
||||
try {
|
||||
$this->results = array();
|
||||
$this->num_fields = odbc_num_fields($odbc_result);
|
||||
$this->num_rows = odbc_num_rows($odbc_result);
|
||||
|
||||
if ($this->num_fields > 0) {
|
||||
while ($row = odbc_fetch_row($odbc_result)) {
|
||||
@@ -94,6 +96,11 @@ class OdbcResultSet implements \Iterator, \ArrayAccess
|
||||
}
|
||||
}
|
||||
|
||||
public function get_num_rows()
|
||||
{
|
||||
return $this->num_rows;
|
||||
}
|
||||
|
||||
public function is_error()
|
||||
{
|
||||
return ($this->error ? true : false);
|
||||
|
||||
@@ -76,7 +76,7 @@ class User extends DbMapping
|
||||
REPLACE(UserAccountNr, ' ', '') AS login
|
||||
FROM [UserAccounts] AS u
|
||||
LEFT JOIN [Addresses] AS a ON a.[AddressID] = u.[ActualAddressID]
|
||||
WHERE REPLACE(UserAccountNr, ' ', '') = '%s' AND disabled = 1 %s;",
|
||||
WHERE LTRIM(RTRIM(UserAccountNr)) = '%s' AND disabled = 1 %s;",
|
||||
$login, $cond);
|
||||
|
||||
$results = Connection::execute($sql, $raiseError);
|
||||
@@ -98,11 +98,14 @@ class User extends DbMapping
|
||||
|
||||
$circulations = $result->to_array();
|
||||
$ids = array_map(function($c) { return $c['NoticeID']; }, $circulations);
|
||||
$books = BookSearch::GetBooks($ids, 'id');
|
||||
$books = count($ids) > 0 ? BookSearch::GetBooks($ids, 'id') : array();
|
||||
|
||||
foreach($circulations as $c) {
|
||||
$books[$c['NoticeID']]['date'] = $c['CheckOutDate'];
|
||||
$books[$c['NoticeID']]['itemNr'] = $c['ItemNr'];
|
||||
$id = $c['NoticeID'];
|
||||
if(isset($books[$id])) {
|
||||
$books[$id]['date'] = $c['CheckOutDate'];
|
||||
$books[$id]['itemNr'] = $c['ItemNr'];
|
||||
}
|
||||
}
|
||||
|
||||
return $books;
|
||||
@@ -145,8 +148,8 @@ class User extends DbMapping
|
||||
WHERE LTRIM(RTRIM(NoticeNr)) = '%s';",
|
||||
$row['WishID'], $this->id, $employee_id, $library_id, $noticeNr);
|
||||
|
||||
Connection::execute($sql);
|
||||
return true;
|
||||
$status = Connection::execute($sql);
|
||||
return $status && ! $status->is_error() && $status->get_num_rows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +179,7 @@ class User extends DbMapping
|
||||
{
|
||||
$sql = sprintf("SELECT TOP $limit
|
||||
NoticeID
|
||||
FROM Wished
|
||||
FROM Wishes
|
||||
WHERE UserAccountID = %s
|
||||
ORDER BY CreationDate DESC", $this->id);
|
||||
|
||||
@@ -188,6 +191,7 @@ class User extends DbMapping
|
||||
/**
|
||||
* Remove a book from the wish list
|
||||
* @param string $noticeNr
|
||||
* @return boolean Was the deletion was successful or not ?
|
||||
*/
|
||||
public function deleteWish($noticeNr)
|
||||
{
|
||||
@@ -197,6 +201,7 @@ class User extends DbMapping
|
||||
WHERE
|
||||
LTRIM(RTRIM(n.NoticeNr)) = '%s'
|
||||
AND UserAccountID = %s;", $noticeNr, $this->id);
|
||||
Connection::execute($sql, true);
|
||||
$status = Connection::execute($sql, true);
|
||||
return $status && ! $status->is_error() && $status->get_num_rows() > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user