BeginTransaction(); if ($status) { $query = "SELECT holding.holdingid, holding.quantity, holding.purchaseprice, holding.purchasedate, holding.quote_symbol,holding.account_accountid FROM holding WHERE holdingid= '$sellInfo->holdingID'"; $result = $db->ExecuteQuery($query); $symbol = $db->GetSQLValue($result, 0, 4); if ($symbol) { $order = createOrder($sellInfo->userID, $symbol, ORDER_TYPE_SELL, $sellInfo->quantity, $sellInfo->holdingID, $db); /*$order->openDate = "2008-05-30T19:27:30.78125+05:30"; $order->completionDate = "2008-05-30T19:27:30.890625+05:30";*/ $order->orderStatus = "open"; if ($order) { processSubmitOrder($order); $response = new sellEnhancedResponse(); $response->sellEnhancedReturn = new OrderDataBean(); $response->sellEnhancedReturn = $order; $db->CommitTransaction(); } else { $db->RollbackTransaction(); } } else { $db->RollbackTransaction(); } $db->CloseDatabase(); } } return $response; } /** * This is the utility method to get the Top orders of a user. * @param userID is the userID of a particular user. * @return an array of OrderDataBean objects. */ function processGetTopOrders($userID) { $db = GetDatabase(); $response = null; if($db) { $query = "SELECT orderid, ordertype, orderstatus, opendate, completiondate, quantity, price, orderfee, quote_symbol FROM orders WHERE orders.account_accountid = (SELECT account.accountid FROM account WHERE account.profile_userid = '$userID') ORDER BY orders.orderid DESC"; $result = $db->ExecuteQuery($query); if($result) { $response = new getOrdersResponse(); $response->getOrdersReturn = new ArrayOfOrderDataBean(); $rawNo = 0; while(($orderID = $db->GetSQLValue($result, $rawNo, 0))) { $response->getOrdersReturn->OrderDataBean[$rawNo] = new OrderDataBean(); $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderID = $orderID; $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderType = $db->GetSQLValue($result, $rawNo, 1); $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderStatus = $db->GetSQLValue($result, $rawNo, 2); $response->getOrdersReturn->OrderDataBean[$rawNo]-> openDate = formatDate($db->GetSQLValue($result, $rawNo, 3)); $response->getOrdersReturn->OrderDataBean[$rawNo]-> completionDate = formatDate($db->GetSQLValue($result, $rawNo, 4)); $response->getOrdersReturn->OrderDataBean[$rawNo]-> quantity = $db->GetSQLValue($result, $rawNo, 5); $response->getOrdersReturn->OrderDataBean[$rawNo]-> price = $db->GetSQLValue($result, $rawNo, 6); $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderFee = $db->GetSQLValue($result, $rawNo, 7); $response->getOrdersReturn->OrderDataBean[$rawNo]-> symbol = $db->GetSQLValue($result, $rawNo, 8); $rawNo = $rawNo + 1; if ($rawNo == TOP_ORDERS) { break; } } } $db->CloseDatabase(); } return $response; } /** * This utility method get the holding information of a particualr holding. * @param holdingInfo holdingID, and the userID * @return a HoldingDataBean object, which the holding information. */ function processGetHolding($holdingInfo) { $db = GetDatabase(); $response = null; if($db) { $query = "SELECT holding.account_accountid, holding.quantity, holding.purchaseprice, holding.purchasedate, holding.quote_symbol FROM holding WHERE holding.holdingid='$holdingInfo->holdingID' AND holding.account_accountid = (SELECT accountid FROM account WHERE profile_userid = '$holdingInfo->userID')"; $result = $db->ExecuteQuery($query); if ($result) { $response = new getHoldingResponse(); $response->getHoldingReturn = new HoldingDataBean(); $response->getHoldingReturn->holdingID = $holdingInfo->holdingID; $response->getHoldingReturn->quantity = $db->GetSQLValue($result, 0, 1); $response->getHoldingReturn->purchasePrice = $db->GetSQLValue($result, 0, 2); $response->getHoldingReturn->purchaseDate = formatDate($db->GetSQLValue($result, 0, 3)); $response->getHoldingReturn->quoteID = $db->GetSQLValue($result, 0, 4); } $db->CloseDatabase(); } return $response; } /** * This utility method is used to register a new user into the system. * @param userInfo, information required to register a new user to the system. * @return an AccountDataBean object correspond to the registered user. */ function processRegister($userInfo) { $db = GetDatabase(); $response = null; if($db) { $queryAccount = "INSERT INTO account (creationdate, openbalance, logoutcount, balance, lastlogin, logincount, profile_userid) VALUES (CURRENT_TIMESTAMP, '$userInfo->openBalance', '0', '$userInfo->openBalance', CURRENT_TIMESTAMP, '0', '$userInfo->userID')"; $queryAccountProfile = "INSERT INTO accountprofile VALUES ('$userInfo->address', '$userInfo->password', '$userInfo->userID', '$userInfo->email', '$userInfo->creditcard', '$userInfo->fullname')"; $result = $db->ExecuteQuery($queryAccountProfile); if ($result) { $result = null; $result = $db->ExecuteQuery($queryAccount); $accountID = $db->GetInsertID(); if (($accountID) && ($accountID != -1)) { $response = new registerResponse(); $response->registerReturn = new AccountDataBean(); $response->registerReturn->accountID = $accountID; $response->registerReturn->loginCount = 0; $response->registerReturn->logoutCount = 0; $response->registerReturn->balance = $userInfo->openBalance; $response->registerReturn->openBalance = $userInfo->openBalance; $response->registerReturn->profileID = $accountID; } } $db->CloseDatabase(); } return $response; } /** * This utility method is used to get MarketSummary information. * @return a getMarketSummary object with market summary information. */ function processGetMarketSummary() { $db = GetDatabase(); $response = null; if($db) { $queryTSIA = "SELECT SUM(price)/COUNT(*) AS tsia FROM quote WHERE symbol like 's:%'"; $queryOPENTSIA = "SELECT SUM(open1)/COUNT(*) AS openTSIA FROM quote WHERE symbol LIKE 's:%'"; $queryVolume = "SELECT SUM(volume) FROM quote WHERE symbol LIKE 's:%'"; $queryGainers = "SELECT symbol, companyname, volume, price, open1, low, high, change1 FROM quote WHERE symbol LIKE 's:%' ORDER BY change1 DESC"; $queryLosers = "SELECT symbol, companyname, volume, price, open1, low, high, change1 FROM quote WHERE symbol LIKE 's:%' ORDER BY change1"; $response = new getMarketSummaryResponse(); $response->getMarketSummaryReturn = new MarketSummaryDataBeanWS(); $result = $db->ExecuteQuery($queryTSIA); if ($result) { $response->getMarketSummaryReturn->TSIA = $db->GetSQLValue($result, 0, 0); $result = null; } $result = $db->ExecuteQuery($queryOPENTSIA); if ($result) { $response->getMarketSummaryReturn->openTSIA = $db->GetSQLValue($result, 0, 0); $result = null; } $result = $db->ExecuteQuery($queryVolume); if($result) { $response->getMarketSummaryReturn->volume = $db->GetSQLValue($result, 0, 0); $result = null; } $result = $db->ExecuteQuery($queryGainers); if($result) { $response->getMarketSummaryReturn->topGainers = new ArrayOfQuoteDataBean(); $rawNo = 0; while(($symbol = $db->GetSQLValue($result, $rawNo, 0)) && $rawNo < 5) { $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo] = new QuoteDataBean(); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->symbol = $symbol; $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->companyName = $db->GetSQLValue($result, $rawNo, 1); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->volume = $db->GetSQLValue($result, $rawNo, 2); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->price = $db->GetSQLValue($result, $rawNo, 3); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->open = $db->GetSQLValue($result, $rawNo, 4); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->low = $db->GetSQLValue($result, $rawNo, 5); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->high = $db->GetSQLValue($result, $rawNo, 6); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->change = $db->GetSQLValue($result, $rawNo, 7); $rawNo = $rawNo + 1; } $result = null; } $result = $db->ExecuteQuery($queryLosers); if($result) { $response->getMarketSummaryReturn->topLosers = new ArrayOfQuoteDataBean(); $rawNo = 0; while(($symbol = $db->GetSQLValue($result, $rawNo, 0)) && $rawNo < 5) { $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo] = new QuoteDataBean(); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->symbol = $symbol; $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->companyName = $db->GetSQLValue($result, $rawNo, 1); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->volume = $db->GetSQLValue($result, $rawNo, 2); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->price = $db->GetSQLValue($result, $rawNo, 3); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->open = $db->GetSQLValue($result, $rawNo, 4); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->low = $db->GetSQLValue($result, $rawNo, 5); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->high = $db->GetSQLValue($result, $rawNo, 6); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->change = $db->GetSQLValue($result, $rawNo, 7); $rawNo = $rawNo + 1; } $result = null; } /*$result = $db->ExecuteQuery($querySummaryDate); if($result) { $response->getMarketSummaryReturn->summaryDate = $db->GetSQLValue($result, 0, 0); $result = null; }*/ $db->CloseDatabase(); } return $response; } /** * This utility method is used to get accountID corresond to a particular userID. * @param userID userID. * @param db database object * @return the accountID of the user. */ function getAccountID($userID, $db) { $response = null; $query = "SELECT accountid FROM account WHERE profile_userid = '$userID'"; $result = $db->ExecuteQuery($query); if($result) { $response = $db->GetSQLValue($result, 0, 0); } return $response; } /** * This utility method is used to create an order in the system. * @param userID userID * @param symbol symbol * @param orderType type of the order (buy|sell) * @param quantity amount (buy|sell) * @param holdingID holdingID of the order (apply for sell) * @param db database object * @return an OrderDataBean object. */ function createOrder($userID, $symbol, $orderType, $quantity, $holdingID, $db) { $order = null; $order = new OrderDataBean(); $order->price = INITIAL_ORDER_PRICE; $order->orderType = $orderType; $order->orderStatus = "open"; $order->quantity = $quantity; $order->symbol = $symbol; if ($orderType == ORDER_TYPE_BUY) { $order->orderFee = BUY_ORDER_FEE; } elseif ($orderType == ORDER_TYPE_SELL) { $order->orderFee = SELL_ORDER_FEE; } $query = "INSERT INTO orders (opendate, orderfee, price, quote_symbol, quantity, ordertype, orderstatus, account_accountid, holding_holdingid) VALUES (CURRENT_TIMESTAMP, '$order->orderFee', '$order->price', '$order->symbol', '$order->quantity', '$orderType', 'open', '".getAccountID($userID, $db)."', '$holdingID')"; $result = $db->ExecuteQuery($query); $order->orderID = $db->GetInsertID(); return $order; } /** * This is the utility method to process a sell request. * After creating an order, it passes it to order processor for * further processing. * @param buyInfo contains buy operation information. * @return an order object correspond to the order. */ function processBuy($buyInfo) { $db = GetDatabase(); $response = null; if ($db) { $status = $db->BeginTransaction(); $order = createOrder($buyInfo->userID, $buyInfo->symbol, ORDER_TYPE_BUY, $buyInfo->quantity, INITIAL_HOLDING_ID, $db); /*$order->openDate = "2008-05-30T19:27:30.78125+05:30"; $order->completionDate = "2008-05-30T19:27:30.890625+05:30";*/ $order->orderStatus = "open"; if ($order) { processSubmitOrder($order); $response = new buyResponse(); $response->buyReturn = new OrderDataBean(); $response->buyReturn = $order; $db->CommitTransaction(); } else { $db->RollbackTransaction(); } $db->CloseDatabase(); } return $response; } /** * This method is used by the ConfigWeb application to check the connectivity. * @return a QuoteDataBean object with nill */ function connectivityResponse() { $response = new getQuoteResponse(); $response->getQuoteReturn = new QuoteDataBean(); return $response; } /** * This is the utility method to process a getQuote request. * @param symbol symbol. * @return a QuoteDataBean object. */ function processGetQuote($symbol) { if ($symbol) { $db = GetDatabase(); $response = null; if($db) { $query = "SELECT symbol, companyname, volume, price, open1, low, high, change1 FROM quote WHERE symbol = '$symbol'"; $result = $db->ExecuteQuery($query); if ($result) { $response = new getQuoteResponse(); $response->getQuoteReturn = new QuoteDataBean(); $response->getQuoteReturn->symbol = $db->GetSQLValue($result, 0, 0); $response->getQuoteReturn->companyName = $db->GetSQLValue($result, 0, 1); $response->getQuoteReturn->volume = $db->GetSQLValue($result, 0, 2); $response->getQuoteReturn->price = $db->GetSQLValue($result, 0, 3); $response->getQuoteReturn->open = $db->GetSQLValue($result, 0, 4); $response->getQuoteReturn->low = $db->GetSQLValue($result, 0, 5); $response->getQuoteReturn->high = $db->GetSQLValue($result, 0, 6); $response->getQuoteReturn->change = $db->GetSQLValue($result, 0, 7); } $db->CloseDatabase(); } } else { $response = connectivityResponse(); } return $response; } /** * This is the utility method that update Account profile information. * @param profileInfo information that needs to be updated in the profile. * @return a AccountProfileDataBean object. */ function processUpdateAccountProfile($profileInfo) { $db = GetDatabase(); $response = null; if($db) { $query = "UPDATE accountprofile SET address='$profileInfo->address', password='$profileInfo->password', email='$profileInfo->email', creditcard = '$profileInfo->creditCard', fullname='$profileInfo->fullName' WHERE userid= '$profileInfo->userID'"; $result = $db->ExecuteQuery($query); if($result) { $response = new updateAccountProfileResponse(); $response->updateAccountProfileReturn = new AccountProfileDataBean(); $response->updateAccountProfileReturn->userID = $profileInfo->userID; $response->updateAccountProfileReturn->password = $profileInfo->password; $response->updateAccountProfileReturn->fullName = $profileInfo->fullName; $response->updateAccountProfileReturn->address = $profileInfo->address; $response->updateAccountProfileReturn->email = $profileInfo->email; $response->updateAccountProfileReturn->creditCard = $profileInfo->creditCard; } else { } $db->CloseDatabase(); } return $response; } /** * Is used to process a logout request * @param userID userID * @return logoutResponse object */ function processLogout($userID) { $db = GetDatabase(); $response = null; if($db) { $query = "UPDATE account SET logoutcount = (logoutcount + 1) WHERE profile_userid= '$userID'"; $result = $db->ExecuteQuery($query); if($result) { $response = new logoutResponse(); } $db->CloseDatabase(); } return $response; } /** * This method is used to get the holdings of a particular user. * @param userID userID * @return an array of HoldingDataBean objects. */ function processGetHoldings($userID) { $db = GetDatabase(); $response = null; if($db) { $query = "SELECT holding.holdingid, holding.quantity, holding.purchaseprice, holding.purchasedate, holding.quote_symbol,holding.account_accountid FROM holding WHERE holding.account_accountid = (SELECT accountid FROM account WHERE profile_userid = '$userID') ORDER BY holding.holdingid DESC"; $result = $db->ExecuteQuery($query); if($result) { $response = new getHoldingsResponse(); $response->getHoldingsReturn = new ArrayOfHoldingDataBean(); $rawNo = 0; while(($holdingID = $db->GetSQLValue($result, $rawNo, 0))) { $response->getHoldingsReturn->HoldingDataBean[$rawNo] = new HoldingDataBean(); $response->getHoldingsReturn->HoldingDataBean[$rawNo]-> holdingID = $db->GetSQLValue($result, $rawNo, 0); $response->getHoldingsReturn->HoldingDataBean[$rawNo]-> quantity = $db->GetSQLValue($result, $rawNo, 1); $response->getHoldingsReturn->HoldingDataBean[$rawNo]-> purchasePrice = $db->GetSQLValue($result, $rawNo, 2); $response->getHoldingsReturn->HoldingDataBean[$rawNo]-> purchaseDate = formatDate($db->GetSQLValue($result, $rawNo, 3)); $response->getHoldingsReturn->HoldingDataBean[$rawNo]-> quoteID = $db->GetSQLValue($result, $rawNo, 4); $rawNo = $rawNo + 1; } } $db->CloseDatabase(); } return $response; } /** * This method obtains the set of closed orders. * @param userID userID * @return an array of OrderDataBean objects */ function processGetClosedOrders($userID) { $db = GetDatabase(); $response = null; if ($db) { $query = "SELECT orderid, ordertype, orderstatus, completiondate, opendate, quantity, price, orderfee, quote_symbol FROM orders WHERE account_accountid = (SELECT accountid FROM account WHERE profile_userid = '$userID') AND orderstatus = 'closed'"; $result = $db->ExecuteQuery($query); if ($result) { $response = new getClosedOrdersResponse(); $response->getClosedOrdersReturn = new ArrayOfOrderDataBean(); $rawNo = 0; while(($orderID = $db->GetSQLValue($result, $rawNo, 0))) { $response->getClosedOrdersReturn->OrderDataBean[$rawNo] = new OrderDataBean(); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> orderID = $orderID; $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> orderType = $db->GetSQLValue($result, 0, 1); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> orderStatus = $db->GetSQLValue($result, $rawNo, 2); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> completionDate = formatDate($db->GetSQLValue($result, $rawNo, 3)); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> openDate = formatDate($db->GetSQLValue($result, $rawNo, 4)); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> quantity = $db->GetSQLValue($result, $rawNo, 5); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> price = $db->GetSQLValue($result, $rawNo, 6); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> orderFee = $db->GetSQLValue($result, $rawNo, 7); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> symbol = $db->GetSQLValue($result, $rawNo, 8); $rawNo = $rawNo + 1; } $query = "UPDATE orders SET orderstatus = 'completed' WHERE orderstatus = 'closed' AND account_accountid = (SELECT accountid FROM account WHERE profile_userid = '$userID')"; $db->ExecuteQuery($query); } $db->CloseDatabase(); } return $response; } /** * This method is a utility method which obtains the AccountProfileData of * a user. * @param userID userID * @return an AccountProfileDataBean object. */ function processGetAccountProfileData($userID) { $db = GetDatabase(); $response = null; if($db) { $query = "SELECT accountprofile.userid, accountprofile.password, accountprofile.fullname, accountprofile.address, accountprofile.email, accountprofile.creditcard FROM accountprofile WHERE accountprofile.userid = '$userID'"; $result = $db->ExecuteQuery($query); if($result) { $response = new getAccountProfileDataResponse(); $response->getAccountProfileDataReturn = new AccountProfileDataBean(); $response->getAccountProfileDataReturn->userID = $userID; $response->getAccountProfileDataReturn->password = $db->GetSQLValue($result, 0, 1); $response->getAccountProfileDataReturn->fullName = $db->GetSQLValue($result, 0, 2); $response->getAccountProfileDataReturn->address = $db->GetSQLValue($result, 0, 3); $response->getAccountProfileDataReturn->email = $db->GetSQLValue($result, 0, 4); $response->getAccountProfileDataReturn->creditCard = $db->GetSQLValue($result, 0, 5); } $db->CloseDatabase(); } return $response; } /** * This method is used to get the Account data of a particular user. * @param userID userID * @return an AccountDataBean object */ function processGetAccountData($userID) { $db = GetDatabase(); $response = null; if($db) { $query = "SELECT account.accountid, account.profile_userid, account.creationdate, account.openbalance, account.logoutcount, account.balance, account.lastlogin, account.logincount FROM account WHERE account.profile_userid = '$userID'"; $result = $db->ExecuteQuery($query); if ($result) { $response = new getAccountDataResponse(); $response->getAccountDataReturn = new AccountDataBean(); $response->getAccountDataReturn->accountID = $db->GetSQLValue($result, 0, 0); $response->getAccountDataReturn->profileID = $db->GetSQLValue($result, 0, 1); $response->getAccountDataReturn->creationDate = formatDate($db->GetSQLValue($result, 0, 2)); $response->getAccountDataReturn->openBalance = $db->GetSQLValue($result, 0, 3); $response->getAccountDataReturn->logoutCount = $db->GetSQLValue($result, 0, 4); $response->getAccountDataReturn->balance = $db->GetSQLValue($result, 0, 5); $response->getAccountDataReturn->lastLogin = formatDate($db->GetSQLValue($result, 0, 6)); $response->getAccountDataReturn->loginCount = $db->GetSQLValue($result, 0, 7); } $db->CloseDatabase(); } return $response; } /** * This method is used to get the orders that a particular user has placed. * @param userID userID * @return an array of OrderDataBean objects. */ function processGetOrders($userID) { $db = GetDatabase(); $response = null; if($db) { $query = "SELECT orderid, ordertype, orderstatus, opendate, completiondate, quantity, price, orderfee, quote_symbol FROM orders WHERE orders.account_accountid = (SELECT account.accountid FROM account WHERE account.profile_userid = '$userID') ORDER BY orders.orderid DESC"; $result = $db->ExecuteQuery($query); if($result) { $response = new getOrdersResponse(); $response->getOrdersReturn = new ArrayOfOrderDataBean(); $rawNo = 0; while(($orderID = $db->GetSQLValue($result, $rawNo, 0))) { $response->getOrdersReturn->OrderDataBean[$rawNo] = new OrderDataBean(); $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderID = $orderID; $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderType = $db->GetSQLValue($result, $rawNo, 1); $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderStatus = $db->GetSQLValue($result, $rawNo, 2); $response->getOrdersReturn->OrderDataBean[$rawNo]-> openDate = formatDate($db->GetSQLValue($result, $rawNo, 3)); $response->getOrdersReturn->OrderDataBean[$rawNo]-> completionDate = formatDate($db->GetSQLValue($result, $rawNo, 4)); $response->getOrdersReturn->OrderDataBean[$rawNo]-> quantity = $db->GetSQLValue($result, $rawNo, 5); $response->getOrdersReturn->OrderDataBean[$rawNo]-> price = $db->GetSQLValue($result, $rawNo, 6); $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderFee = $db->GetSQLValue($result, $rawNo, 7); $response->getOrdersReturn->OrderDataBean[$rawNo]-> symbol = $db->GetSQLValue($result, $rawNo, 8); $rawNo = $rawNo + 1; } } $db->CloseDatabase(); } return $response; } /** * This method is used to process a login request. * @param userID userID * @param password password * @return an AccountDataBean object. */ function processLogin($userID, $password) { $db = GetDatabase(); $response = null; if ($db) { $query = "SELECT accountprofile.userid, accountprofile.password, accountprofile.fullname, accountprofile.address, accountprofile.email, accountprofile.creditcard FROM accountprofile WHERE accountprofile.userid = '$userID'"; $result = $db->ExecuteQuery($query); if ($password == $db->GetSQLValue($result, 0, 1)) { $query = "UPDATE account SET logincount = (logincount + 1), lastlogin = CURRENT_TIMESTAMP WHERE profile_userid = '$userID'"; $result = $db->ExecuteQuery($query); $query = "SELECT account.accountid, account.creationdate, account.openbalance, account.logoutcount, account.balance, account.lastlogin, account.logincount FROM account WHERE account.profile_userid = '$userID'"; $result = null; $result = $db->ExecuteQuery($query); if ($result) { $response = new loginResponse(); $response->loginReturn = new AccountDataBean(); $response->loginReturn->accountID = $db->GetSQLValue($result, 0, 0); $response->loginReturn->creationDate = formatDate($db->GetSQLValue($result, 0, 1)); $response->loginReturn->openBalance = $db->GetSQLValue($result, 0, 2); $response->loginReturn->logoutCount = $db->GetSQLValue($result, 0, 3); $response->loginReturn->balance = $db->GetSQLValue($result, 0, 4); $response->loginReturn->lastLogin = formatDate($db->GetSQLValue($result, 0, 5)); $response->loginReturn->loginCount = $db->GetSQLValue($result, 0, 6); $response->loginReturn->profileID = $userID; } } $db->CloseDatabase(); } return $response; } /** * This function formats the incoming date into the format * yy-mm-ddThh-min-sec format */ function formatDate($dateString) { return date ("Y-m-d\TH:i:s.100", strtotime($dateString)); } ?>