function __construct($email = null)
 {
     $email = urldecode($email);
     // halt on error: wrong email format
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         throw new Exception('JAC_User_WrongEmail: Format of the provided email address is not correct.');
         return;
     }
     // email address is valid - assign the value
     $this->email = $email;
     // load the user or create one if it does not exists (by email address)
     $this->dbPointer = R::findOrCreate('user', array('email' => $email));
     // assign the values from DB
     $this->name = $this->dbPointer->name;
     $this->id = $this->dbPointer->id;
 }
 /**
  * mark user as unsynced in cased user is updated
  * @param int $userId id of the user to be marked as unsynced
  * @return boolean
  * **/
 public function markUserAsUnsynced($userId)
 {
     $userRow = \R::findOrCreate($this->_name, array("users_id" => $userId));
     $userRow->ams_sync_status = 0;
     $userRow->amt_sync_status = 0;
     $userRow->dmb_sync_status = 0;
     try {
         $this->_redBeans->store($userRow);
         //         //lets send ipn to all clients
         //         $objIpnHandler = new ipn\IpnHandler();
         //         $objIpnHandler->sendIpnForUpdatedUser($userId);
         return true;
     } catch (\Exception $ex) {
         return false;
     }
     return false;
 }
            if (in_array($img_base64, $null_image) !== FALSE) {
                $img_base64 = NULL;
            }
        }
        $available_td_list = $qp->find('.bibItemsEntry td:contains("可流通")');
        for ($i = 0; $i < $available_td_list->size(); $i++) {
            $call_number = $available_td_list->eq($i)->prev()->text();
            $call_number = trim($call_number);
            $location = $available_td_list->eq($i)->prev()->prev()->text();
            $location = trim($location);
            $data[] = array("title" => $title, "call_number" => $call_number, "location" => $location, "isbn" => $isbn, "img" => $img_base64);
        }
        //    $data = array(
        //        "error" => "NOT_FOUND"
        //    );
    }
}
// if (htmlqp($url, '.bibItemsEntry td:contains("可流通")')->size() > 0) {
// ---------------------------
// 轉換
$json = json_encode($data, JSON_UNESCAPED_UNICODE);
//$json = json_encode($data);
// ---------------------------
// 備份快取資料
$result = R::findOrCreate('cache_query_result', ['isbn' => $isbn]);
$result->isbn = $isbn;
$result->json = $json;
$result->timestamp = time();
R::store($result);
echo $json;
book_list_log($json);