incubator-stonehenge-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shan...@apache.org
Subject svn commit: r771220 - in /incubator/stonehenge/trunk/stocktrader/php: business_service/ config_service/ order_processor/ resources/db_scripts/mysql/
Date Mon, 04 May 2009 07:34:57 GMT
Author: shankar
Date: Mon May  4 07:34:57 2009
New Revision: 771220

URL: http://svn.apache.org/viewvc?rev=771220&view=rev
Log:
Committing patch from STONEHENGE-49

Modified:
    incubator/stonehenge/trunk/stocktrader/php/business_service/business_processor.php
    incubator/stonehenge/trunk/stocktrader/php/config_service/config_svc.php
    incubator/stonehenge/trunk/stocktrader/php/config_service/config_svc_processor.php
    incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor.php
    incubator/stonehenge/trunk/stocktrader/php/resources/db_scripts/mysql/InsertScript.sql
    incubator/stonehenge/trunk/stocktrader/php/resources/db_scripts/mysql/TableCreate.sql

Modified: incubator/stonehenge/trunk/stocktrader/php/business_service/business_processor.php
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/business_service/business_processor.php?rev=771220&r1=771219&r2=771220&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/php/business_service/business_processor.php (original)
+++ incubator/stonehenge/trunk/stocktrader/php/business_service/business_processor.php Mon
May  4 07:34:57 2009
@@ -448,9 +448,9 @@
 		$status = $db->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'";
+			$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);
@@ -500,11 +500,11 @@
 	$response = null;
 	if($db)
 	{
-		$query = "SELECT TOP ".TOP_ORDERS." 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";
+		$query = "SELECT top ".TOP_ORDERS." 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);
 		
@@ -556,12 +556,12 @@
 	$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')";
+        $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)
@@ -590,8 +590,8 @@
 	$response = null;
 	if($db)
 	{
-        $queryAccount = "INSERT INTO account (CREATIONDATE, OPENBALANCE, LOGOUTCOUNT, 
-			BALANCE, LASTLOGIN, LOGINCOUNT, PROFILE_USERID) VALUES (CURRENT_TIMESTAMP, 
+        $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')";
 			
@@ -632,18 +632,18 @@
 	$response = null;
 	if($db)
 	{
-		$queryTSIA = "select SUM(price)/count(*) as 
-				TSIA from quote where symbol like 's:1__'";
-		$queryOPENTSIA = "select SUM(open1)/count(*) as 
-				openTSIA from quote where symbol like 's:1__'";
-		$queryVolume = "SELECT SUM(volume) from quote 
-				where symbol like 's:1__'";
+		$queryTSIA = "SELECT SUM(price)/COUNT(*) AS 
+				tsia FROM quote WHERE symbol like 's:1__'";
+		$queryOPENTSIA = "SELECT SUM(open1)/COUNT(*) AS 
+				openTSIA FROM quote WHERE symbol LIKE 's:1__'";
+		$queryVolume = "SELECT SUM(volume) FROM quote 
+				WHERE symbol LIKE 's:1__'";
 		$queryGainers = "SELECT symbol, companyname, volume, price, 
-				open1, low, high, change1 from quote where symbol 
-				like 's:1__' order by change1 desc";
+				open1, low, high, change1 FROM quote WHERE symbol 
+				LIKE 's:1__' ORDER BY change1 DESC";
 		$queryLosers = "SELECT symbol, companyname, volume, price, 
-				open1, low, high, change1 from quote where symbol 
-				like 's:1__' order by change1";
+				open1, low, high, change1 FROM quote WHERE symbol 
+				LIKE 's:1__' ORDER BY change1";
 		
 		$response = new getMarketSummaryResponse();
 		$response->getMarketSummaryReturn = new MarketSummaryDataBeanWS();
@@ -757,8 +757,8 @@
 function getAccountID($userID, $db)
 {
 	$response = null;
-	$query = "SELECT ACCOUNTID FROM ACCOUNT  
-		WHERE PROFILE_USERID = '$userID'";
+	$query = "SELECT accountid FROM account  
+		WHERE profile_userid = '$userID'";
 	$result = $db->ExecuteQuery($query);
 	if($result)
 	{
@@ -796,8 +796,8 @@
 		$order->orderFee = SELL_ORDER_FEE;
 	}
 	
-	$query = "INSERT INTO ORDERS (OPENDATE, ORDERFEE, PRICE, QUOTE_SYMBOL, QUANTITY, 
-			ORDERTYPE, ORDERSTATUS, ACCOUNT_ACCOUNTID, HOLDING_HOLDINGID) 
+	$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')"; 
@@ -870,7 +870,7 @@
 		if($db)
 		{
 			$query = "SELECT symbol, companyname, volume, price, 
-					open1, low, high, change1 from quote where 
+					open1, low, high, change1 FROM quote WHERE 
 					symbol = '$symbol'";
 			
 			$result = $db->ExecuteQuery($query);
@@ -909,10 +909,10 @@
 	$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'";
+		$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)
@@ -945,8 +945,8 @@
 	$response = null;
 	if($db)
 	{
-        $query = "UPDATE account SET LOGOUTCOUNT = 
-			(LOGOUTCOUNT + 1) where PROFILE_USERID= '$userID'";
+        $query = "UPDATE account SET logoutcount = 
+			(logoutcount + 1) WHERE profile_userid= '$userID'";
 		
 		$result = $db->ExecuteQuery($query);
 		if($result)
@@ -969,10 +969,10 @@
 	$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";
+        $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)
@@ -1014,11 +1014,11 @@
 	$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'";
+        $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);
 		
@@ -1054,9 +1054,9 @@
 				$rawNo = $rawNo + 1;
 			}
 			
-			$query = "UPDATE orders SET ORDERSTATUS = 'completed' where 
-				ORDERSTATUS = 'closed' AND ACCOUNT_ACCOUNTID = (select accountid 
-				from account where profile_userid = '$userID')";
+			$query = "UPDATE orders SET orderstatus = 'completed' WHERE 
+				orderstatus = 'closed' AND account_accountid = (SELECT accountid 
+				FROM account WHERE profile_userid = '$userID')";
 				
 			$db->ExecuteQuery($query);
 		}
@@ -1077,10 +1077,10 @@
 	$response = null;
 	if($db)
 	{
-        $query = "SELECT accountprofile.USERID, accountprofile.PASSWORD, 
-		accountprofile.FULLNAME, accountprofile.ADDRESS, accountprofile.EMAIL, 
-		accountprofile.CREDITCARD FROM accountprofile WHERE 
-		accountprofile.USERID = '$userID'";
+        $query = "SELECT accountprofile.userid, accountprofile.password, 
+		accountprofile.fullname, accountprofile.address, accountprofile.email, 
+		accountprofile.creditcard FROM accountprofile WHERE 
+		accountprofile.userid = '$userID'";
 		
 		$result = $db->ExecuteQuery($query);
 		
@@ -1111,10 +1111,10 @@
 	$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'";
+		$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);
 	
@@ -1147,11 +1147,11 @@
 	$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";
+		$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);
@@ -1205,26 +1205,26 @@
 	$response = null;
 	if ($db)
 	{
-		$query = "SELECT ACCOUNTPROFILE.USERID, 
-			ACCOUNTPROFILE.PASSWORD, ACCOUNTPROFILE.FULLNAME, 
-			ACCOUNTPROFILE.ADDRESS, ACCOUNTPROFILE.EMAIL, 
-			ACCOUNTPROFILE.CREDITCARD FROM ACCOUNTPROFILE 
-			WHERE ACCOUNTPROFILE.USERID = '$userID'";
+		$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'"; 
+			$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'";
+			$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);

Modified: incubator/stonehenge/trunk/stocktrader/php/config_service/config_svc.php
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/config_service/config_svc.php?rev=771220&r1=771219&r2=771220&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/php/config_service/config_svc.php (original)
+++ incubator/stonehenge/trunk/stocktrader/php/config_service/config_svc.php Mon May  4 07:34:57
2009
@@ -39,14 +39,14 @@
 				if($result)
 				{
 					/* this detail is already available. So we should update the records */
-					$query = "UPDATE DBCONFIG WITH (ROWLOCK) SET HOSTNAME='$DBConfig->DBHostName', ".
-					   "PORT='$DBConfig->DBPort' WHERE DBNAME = '$DBConfig->DBName'";
+					$query = "UPDATE dbconfig WITH (ROWLOCK) SET hostname='$DBConfig->DBHostName', ".
+					   "PORT='$DBConfig->DBPort' WHERE dbname = '$DBConfig->DBName'";
 					$status = $db->ExecuteQuery($query);
 				}
 				else
 				{
 					/* details related to this database is not stored. So we have to insert a new record
*/
-					$query = "INSERT INTO DBCONFIG (DBNAME, HOSTNAME, PORT, ACTIVE) VALUES (".
+					$query = "INSERT INTO dbconfig (dbname, hostname, port, active) VALUES (".
 						"'$DBConfig->DBName', '$DBConfig->DBHostName', '$DBConfig->DBPort', 'N');";
 					$status = $db->ExecuteQuery($query);
 				}
@@ -87,7 +87,7 @@
 {
 	$db = GetDatabase();
 
-	$query = "Set NOCOUNT ON; SELECT DBNAME, HOSTNAME, PORT FROM DBCONFIG";
+	$query = "Set NOCOUNT ON; SELECT dbname, hostname, port FROM dbconfig";
 
 	$result =  $db->ExecuteQuery($query);
 	if ($result)
@@ -132,7 +132,7 @@
 				 * the transaction, if something goes wrong. */
 				if($db->ExecuteQuery("BEGIN TRAN"))
 				{
-					$query = "UPDATE DBCONFIG WITH (ROWLOCK) SET ACTIVE='Y' WHERE DBNAME='$DBName'";
+					$query = "UPDATE dbconfig WITH (ROWLOCK) SET active='Y' WHERE dbname='$DBName'";
 					$status = $db->ExecuteQuery($query);
 
 					if($status)
@@ -212,14 +212,14 @@
 				if($result)
 				{
 					/* this detail is already available. So we should update the records */
-					$query = "UPDATE SERVICE WITH (ROWLOCK) SET URL='$ServiceLocation->ServiceURL' ".
+					$query = "UPDATE service WITH (ROWLOCK) SET url='$ServiceLocation->ServiceURL' ".
 					   "WHERE SERVICENAME = '$ServiceLocation->ServiceName'";
 					$status = $db->ExecuteQuery($query);
 				}
 				else
 				{
 					/* details related to this database is not stored. So we have to insert a new record
*/
-					$query = "INSERT INTO SERVICE (SERVICENAME, URL) VALUES (".
+					$query = "INSERT INTO service (servicename, url) VALUES (".
 						"'$ServiceLocation->ServiceName', '$ServiceLocation->ServiceURL')";
 					$status = $db->ExecuteQuery($query);
 				}
@@ -260,7 +260,7 @@
 {
 	$db = GetDatabase();
 
-	$query = "Set NOCOUNT ON; SELECT SERVICENAME, URL FROM SERVICE";
+	$query = "SET NOCOUNT ON; SELECT servicename, url FROM service";
 
 	$result =  $db->ExecuteQuery($query);
 	if ($result)
@@ -305,14 +305,14 @@
 					if($result)
 					{
 						/* this detail is already available. So we should update the records */
-						$query = "UPDATE CLIENTTOBS WITH (ROWLOCK) SET BS='$ClientToBS->BS' ".
-						   "WHERE CLIENT = '$ClientToBS->Client'";
+						$query = "UPDATE clienttobs WITH (ROWLOCK) SET bs='$ClientToBS->BS' ".
+						   "WHERE client = '$ClientToBS->Client'";
 						$status = $db->ExecuteQuery($query);
 					}
 					else
 					{
 						/* details related to this database is not stored. So we have to insert a new record
*/
-						$query = "INSERT INTO CLIENTTOBS (CLIENT, BS) VALUES (".
+						$query = "INSERT INTO clienttobs (client, bs) VALUES (".
 							"'$ClientToBS->Client', '$ClientToBS->BS')";
 						$status = $db->ExecuteQuery($query);
 					}
@@ -357,7 +357,7 @@
 {
 	$db = GetDatabase();
 
-	$query = "Set NOCOUNT ON; SELECT CLIENT, BS FROM CLIENTTOBS";
+	$query = "SET NOCOUNT ON; SELECT client, bs FROM clienttobs";
 
 	$result =  $db->ExecuteQuery($query);
 	if ($result)
@@ -402,14 +402,14 @@
 					if($result)
 					{
 						/* this detail is already available. So we should update the records */
-						$query = "UPDATE BSTOOPS WITH (ROWLOCK) SET OPS='$BSToOPS->OPS' ".
-						   "WHERE BS = '$BSToOPS->BS'";
+						$query = "UPDATE bstoops WITH (ROWLOCK) SET ops='$BSToOPS->OPS' ".
+						   "WHERE bs = '$BSToOPS->BS'";
 						$status = $db->ExecuteQuery($query);
 					}
 					else
 					{
 						/* details related to this database is not stored. So we have to insert a new record
*/
-						$query = "INSERT INTO BSTOOPS (BS, OPS) VALUES ('$BSToOPS->BS', '$BSToOPS->OPS')";
+						$query = "INSERT INTO bstoops (bs, ops) VALUES ('$BSToOPS->BS', '$BSToOPS->OPS')";
 						$status = $db->ExecuteQuery($query);
 					}
 
@@ -453,7 +453,7 @@
 {
 	$db = GetDatabase();
 
-	$query = "Set NOCOUNT ON; SELECT BS, OPS FROM BSTOOPS";
+	$query = "SET NOCOUNT ON; SELECT bs, ops FROM bstoops";
 
 	$result =  $db->ExecuteQuery($query);
 	if ($result)

Modified: incubator/stonehenge/trunk/stocktrader/php/config_service/config_svc_processor.php
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/config_service/config_svc_processor.php?rev=771220&r1=771219&r2=771220&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/php/config_service/config_svc_processor.php (original)
+++ incubator/stonehenge/trunk/stocktrader/php/config_service/config_svc_processor.php Mon
May  4 07:34:57 2009
@@ -138,7 +138,7 @@
  */
 function getServiceLocation($serviceName, $db)
 {
-	$query = "SELECT SERVICENAME, URL FROM SERVICE WHERE SERVICENAME = '$serviceName'";
+	$query = "SELECT servicename, url FROM service WHERE servicename = '$serviceName'";
 
 	$result =  $db->ExecuteQuery($query);
 	if (($result) && ($db->GetSQLValue($result, 0, 0)))	//return value is having
atleast one row
@@ -158,7 +158,7 @@
  */
 function getClientToBS($client, $db)
 {
-	$query = "SELECT CLIENT, BS FROM CLIENTTOBS WHERE CLIENT = '$client'";
+	$query = "SELECT client, bs FROM clienttobs WHERE client = '$client'";
 
 	$result =  $db->ExecuteQuery($query);
 	if (($result) && ($db->GetSQLValue($result, 0, 0)))	//return value is having
atleast one row
@@ -178,7 +178,7 @@
  */
 function getBSToOPS($BS, $db)
 {
-	$query = "SELECT BS, OPS FROM BSTOOPS WHERE BS = '$BS'";
+	$query = "SELECT bs, ops FROM bstoops WHERE bs = '$BS'";
 
 	$result =  $db->ExecuteQuery($query);
 	if (($result) && ($db->GetSQLValue($result, 0, 0)))		//return value is having
atleast one row
@@ -198,7 +198,7 @@
  */
 function getDBConfig($DBName, $db)
 {
-	$query = "SELECT DBNAME, HOSTNAME, PORT FROM DBCONFIG WHERE DBNAME = '$DBName'";
+	$query = "SELECT dbname, hostname, port FROM dbconfig WHERE dbname = '$DBName'";
 
 	$result =  $db->ExecuteQuery($query);
 	if (($result) && ($db->GetSQLValue($result, 0, 0))) 		//return value is having
atleast one row
@@ -218,7 +218,7 @@
  */
 function getActiveDBConfig($db)
 {
-	$query = "SELECT DBNAME, HOSTNAME, PORT FROM DBCONFIG WHERE ACTIVE = 'Y'";
+	$query = "SELECT dbname, hostname, port FROM dbconfig WHERE active = 'Y'";
 
 	$result =  $db->ExecuteQuery($query);
 	if (($result) && ($db->GetSQLValue($result, 0, 0)))		//return value is having
atleast one row

Modified: incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor.php
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor.php?rev=771220&r1=771219&r2=771220&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor.php (original)
+++ incubator/stonehenge/trunk/stocktrader/php/order_processor/order_processor.php Mon May
 4 07:34:57 2009
@@ -183,8 +183,8 @@
 
 function GetQuoteForUpdate($symbol, $db)
 {
-	$query = "SELECT SYMBOL, COMPANYNAME, VOLUME, PRICE, ".
-		"OPEN1, LOW, HIGH, CHANGE1 FROM QUOTE WHERE SYMBOL ".
+	$query = "SELECT symbol, companyname, volume, price, ".
+		"open1, low, high, change1 FROM quote WHERE symbol ".
 		"= '$symbol'";
 
 	/*Get the tuple corresponding to the particular symbol*/
@@ -315,8 +315,8 @@
 
 function UpdateOrder($order, $db)
 {
-	$query = "UPDATE ORDERS SET QUANTITY='$order->quantity' WHERE".
-		" ORDERID='$order->orderID'";
+	$query = "UPDATE orders SET quantity='$order->quantity' WHERE".
+		" orderid='$order->orderID'";
 	return $db->ExecuteQuery($query);
 }
 
@@ -329,8 +329,8 @@
 
 function UpdateHolding($holding, $quantity, $db)
 {
-	$query = "UPDATE HOLDING SET QUANTITY=QUANTITY-'$quantity'".
-		" WHERE HOLDINGID='$holding->holdingID'";
+	$query = "UPDATE holding SET quantity=quantity-'$quantity'".
+		" WHERE holdingid='$holding->holdingID'";
 	return $db->ExecuteQuery($query);
 }
 
@@ -342,8 +342,8 @@
 
 function DeleteHolding($holding, $db)
 {
-	$query = "DELETE FROM HOLDING WHERE ".
-		"HOLDINGID='$holding->holdingID'";
+	$query = "DELETE FROM holding WHERE ".
+		"holdingid='$holding->holdingID'";
 	return $db->ExecuteQuery($query);
 }
 
@@ -356,11 +356,11 @@
 
 function GetHoldingForUpdate($order, $db)
 {
-	$query = "SELECT HOLDING.HOLDINGID, HOLDING.ACCOUNT_ACCOUNTID,".
-		" HOLDING.QUANTITY, HOLDING.PURCHASEPRICE, HOLDING.PURCHASEDATE,".
-		" HOLDING.QUOTE_SYMBOL FROM HOLDING INNER JOIN ORDERS".
-		" ON HOLDING.HOLDINGID = ORDERS.HOLDING_HOLDINGID WHERE ".
-		"(ORDERS.ORDERID = '$order->orderID')";
+	$query = "SELECT holding.holdingid, holding.account_accountid,".
+		" holding.quantity, holding.purchaseprice, holding.purchasedate,".
+		" holding.quote_symbol FROM holding INNER JOIN orders".
+		" ON holding.holdingid = orders.holding_holdingid WHERE ".
+		"(orders.orderid = '$order->orderID')";
 
 	/*Get the machining tuple from HOLDING table, that corresponds to the 
 	current sell operation.*/
@@ -399,10 +399,10 @@
 	{
 		$holdingID = "NULL";
 	}
-	$query = "UPDATE ORDERS SET ".
-		"ORDERSTATUS='".ORDER_STATUS_CLOSED."',".
-		" COMPLETIONDATE=CURRENT_TIMESTAMP, HOLDING_HOLDINGID=$holdingID,".
-		" PRICE='$order->price' WHERE ORDERID='$order->orderID'";
+	$query = "UPDATE orders SET ".
+		"orderstatus='".ORDER_STATUS_CLOSED."',".
+		" completiondate=CURRENT_TIMESTAMP, holding_holdingid=$holdingID,".
+		" price='$order->price' WHERE orderid='$order->orderID'";
 	return $db->ExecuteQuery($query);
 }
 
@@ -418,8 +418,8 @@
 	$accountID = GetAccountIDFromOrder($order, $db);
 	if ($accountID != INVALID_ID)
 	{
-		$query = "INSERT INTO HOLDING (PURCHASEPRICE, QUANTITY, PURCHASEDATE,".
-			" ACCOUNT_ACCOUNTID, QUOTE_SYMBOL) VALUES ('$order->price',".
+		$query = "INSERT INTO holding (purchaseprice, quantity, purchasedate,".
+			" account_accountid, quote_symbol) VALUES ('$order->price',".
 			" '$order->quantity', CURRENT_TIMESTAMP, '$accountID', '$order->symbol')";
 
 		$result = $db->ExecuteQuery($query);
@@ -446,8 +446,8 @@
 
 function GetAccountIDFromOrder($order, $db)
 {
-	$query = "SELECT ACCOUNT_ACCOUNTID FROM ORDERS ".
-		" WHERE ORDERID='$order->orderID'";
+	$query = "SELECT account_accountid FROM orders ".
+		" WHERE orderid='$order->orderID'";
 
 	/*Get a tuple including accountID for a particular order*/
 
@@ -474,8 +474,8 @@
 
 function UpdateAccountBalance($accountID, $amount, $db)
 {
-	$query = "UPDATE ACCOUNT SET BALANCE=(BALANCE - '$amount')".
-		" WHERE ACCOUNTID = '$accountID'";
+	$query = "UPDATE account SET balance=(balance - '$amount')".
+		" WHERE accountid = '$accountID'";
 	return $db->ExecuteQuery($query);
 }
 
@@ -509,9 +509,9 @@
 			$quote->high = $quote->price;
 		}
 
-		$query = "UPDATE QUOTE SET PRICE='$quote->price', ".
-			"LOW='$quote->low', HIGH='$quote->high', CHANGE1='$quote->price' - ".
-			"OPEN1, VOLUME=VOLUME+'$quantity' WHERE SYMBOL='$quote->symbol'";
+		$query = "UPDATE quote SET price='$quote->price', ".
+			"low='$quote->low', high='$quote->high', change1='$quote->price' - ".
+			"open1, volume=volume+'$quantity' WHERE symbol='$quote->symbol'";
 
 		$status = $db->ExecuteQuery($query);
 	}

Modified: incubator/stonehenge/trunk/stocktrader/php/resources/db_scripts/mysql/InsertScript.sql
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/resources/db_scripts/mysql/InsertScript.sql?rev=771220&r1=771219&r2=771220&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/php/resources/db_scripts/mysql/InsertScript.sql
(original)
+++ incubator/stonehenge/trunk/stocktrader/php/resources/db_scripts/mysql/InsertScript.sql
Mon May  4 07:34:57 2009
@@ -14,70 +14,70 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('JAVA_BS','http://localhost:9763/services/TradeServiceWsas');
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('JAVA_OPS','http://localhost:9763/services/OrderProcessor');
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('JAVA_OPSSEC','http://localhost:9763/services/OrderProcessorMsec');
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('PHP_BS','http://localhost:8080/php_stocktrader/business_service/business_svc.php');
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('PHP_OPS','http://localhost:8080/php_stocktrader/order_processor/order_processor_svc.php');
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('PHP_OPSSEC','http://localhost:8080/php_stocktrader/order_processor/order_processor_svc_msec.php');
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('SPRING_BS','http://localhost:8070/StockTrader/services/TradeService');
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('SPRING_OPS','http://localhost:8060/StockTrader/services/OrderService');
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('SPRING_OPSSEC','http://localhost:8060/StockTrader/services/OrderServiceMsec');
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('RUBY_OPS','http://localhost:3005/OrderService');
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('RUBY_OPSSEC','http://localhost:3005/OrderServiceMsec');
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('DOTNET_BS','http://localhost:9000/TradeBusinessService');
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('DOTNET_OPS','http://localhost:8000/TradeOrderProcessor');
-INSERT INTO SERVICE(SERVICENAME,URL)
+INSERT INTO service(servicename,url)
      VALUES ('DOTNET_OPSSEC','http://localhost:8000/TradeOrderProcessor/msec');
-INSERT INTO DBCONFIG(DBNAME,HOSTNAME,PORT,ACTIVE)
+INSERT INTO dbconfig(dbname,hostname,port,active)
      VALUES ('MSSQL', '127.0.0.1', 1433, 'Y');
-INSERT INTO CLIENTTOBS(CLIENT,BS)
+INSERT INTO clienttobs(client,bs)
      VALUES ('PHP_CLIENT','PHP_BS');
-INSERT INTO BSTOOPS(BS,OPS)
+INSERT INTO bstoops(bs,ops)
 	 VALUES ('PHP_BS', 'PHP_OPS');
-INSERT INTO BSTOOPS(BS,OPS)
+INSERT INTO bstoops(bs,ops)
 	 VALUES ('JAVA_BS', 'JAVA_OPS');
 
 
 
 
-INSERT INTO ACCOUNT(CREATIONDATE, OPENBALANCE, LOGOUTCOUNT, BALANCE, LASTLOGIN, LOGINCOUNT,
PROFILE_USERID)
+INSERT INTO account(creationdate, openbalance, logoutcount, balance, lastlogin, logincount,
profile_userid)
 	VALUES ('2008-01-01 00:00:00', 10000, 1, 10000, '2008-01-01 00:00:00', 1, 'uid:0');
-INSERT INTO ACCOUNTPROFILE(ADDRESS,PASSWORD,USERID,EMAIL,CREDITCARD,FULLNAME)
+INSERT INTO accountprofile(address,password,userid,email,creditcard,fullname)
      VALUES ('111 First Street, Redmond, WA33', 'xxx', 'uid:0', 'user0@company.com', '469023-0320',
'Full Name 0');
 
-INSERT INTO QUOTE (LOW,OPEN1,VOLUME,PRICE,HIGH,COMPANYNAME,SYMBOL,CHANGE1)
+INSERT INTO quote (low,open1,volume,price,high,companyname,symbol,change1)
      VALUES (100, 100, 1000, 100, 100, 'S0 Incorp', 's:0', 0);
-INSERT INTO QUOTE (LOW,OPEN1,VOLUME,PRICE,HIGH,COMPANYNAME,SYMBOL,CHANGE1)
+INSERT INTO quote (low,open1,volume,price,high,companyname,symbol,change1)
      VALUES (100, 100, 1000, 100, 100, 'S1 Incorp', 's:1', 0);
-INSERT INTO QUOTE (LOW,OPEN1,VOLUME,PRICE,HIGH,COMPANYNAME,SYMBOL,CHANGE1)
+INSERT INTO quote (low,open1,volume,price,high,companyname,symbol,change1)
      VALUES (100, 100, 1000, 100, 100, 'S2 Incorp', 's:2', 0);
-INSERT INTO QUOTE (LOW,OPEN1,VOLUME,PRICE,HIGH,COMPANYNAME,SYMBOL,CHANGE1)
+INSERT INTO quote (low,open1,volume,price,high,companyname,symbol,change1)
      VALUES (100, 100, 1000, 100, 100, 'S3 Incorp', 's:3', 0);
-INSERT INTO QUOTE (LOW,OPEN1,VOLUME,PRICE,HIGH,COMPANYNAME,SYMBOL,CHANGE1)
+INSERT INTO quote (low,open1,volume,price,high,companyname,symbol,change1)
      VALUES (100, 100, 1000, 100, 100, 'S4 Incorp', 's:4', 0);
-INSERT INTO QUOTE (LOW,OPEN1,VOLUME,PRICE,HIGH,COMPANYNAME,SYMBOL,CHANGE1)
+INSERT INTO quote (low,open1,volume,price,high,companyname,symbol,change1)
      VALUES (100, 100, 1000, 100, 100, 'S5 Incorp', 's:5', 0);
-INSERT INTO QUOTE (LOW,OPEN1,VOLUME,PRICE,HIGH,COMPANYNAME,SYMBOL,CHANGE1)
+INSERT INTO quote (low,open1,volume,price,high,companyname,symbol,change1)
      VALUES (100, 100, 1000, 100, 100, 'S6 Incorp', 's:6', 0);
-INSERT INTO QUOTE (LOW,OPEN1,VOLUME,PRICE,HIGH,COMPANYNAME,SYMBOL,CHANGE1)
+INSERT INTO quote (low,open1,volume,price,high,companyname,symbol,change1)
      VALUES (100, 100, 1000, 100, 100, 'S7 Incorp', 's:7', 0);
-INSERT INTO QUOTE (LOW,OPEN1,VOLUME,PRICE,HIGH,COMPANYNAME,SYMBOL,CHANGE1)
+INSERT INTO quote (low,open1,volume,price,high,companyname,symbol,change1)
      VALUES (100, 100, 1000, 100, 100, 'S8 Incorp', 's:8', 0);
-INSERT INTO QUOTE (LOW,OPEN1,VOLUME,PRICE,HIGH,COMPANYNAME,SYMBOL,CHANGE1)
+INSERT INTO quote (low,open1,volume,price,high,companyname,symbol,change1)
      VALUES (100, 100, 1000, 100, 100, 'S9 Incorp', 's:9', 0);
 
 

Modified: incubator/stonehenge/trunk/stocktrader/php/resources/db_scripts/mysql/TableCreate.sql
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/php/resources/db_scripts/mysql/TableCreate.sql?rev=771220&r1=771219&r2=771220&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/php/resources/db_scripts/mysql/TableCreate.sql
(original)
+++ incubator/stonehenge/trunk/stocktrader/php/resources/db_scripts/mysql/TableCreate.sql
Mon May  4 07:34:57 2009
@@ -15,79 +15,84 @@
  * limitations under the License.
  */
 
-CREATE TABLE IF NOT EXISTS ACCOUNT(
-			CREATIONDATE datetime NULL,
-			OPENBALANCE decimal(12, 2) NULL,
-			LOGOUTCOUNT integer NOT NULL,
-			BALANCE decimal(12, 2) NULL,
-			ACCOUNTID integer AUTO_INCREMENT NOT NULL,
-			LASTLOGIN datetime NULL,
-			LOGINCOUNT integer NOT NULL,
-			PROFILE_USERID varchar(250) NULL,
-			PRIMARY KEY (ACCOUNTID));
-
-CREATE TABLE IF NOT EXISTS ACCOUNTPROFILE(
-			ADDRESS varchar(250) NULL,
-			PASSWORD varchar(250) NULL,
-			USERID varchar(250) NOT NULL,
-			EMAIL varchar(250) NULL,
-			CREDITCARD varchar(250) NULL,
-			FULLNAME varchar(250) NULL,
-			PRIMARY KEY (USERID));
-
-CREATE TABLE IF NOT EXISTS stocktraderdb.QUOTE(
-			LOW decimal(12, 2) NULL,
-			OPEN1 decimal(12, 2) NULL,
-			VOLUME float NOT NULL,
-			PRICE decimal(12, 2) NULL,
-			HIGH decimal(12, 2) NULL,
-			COMPANYNAME varchar(250) NULL,
-			SYMBOL varchar(250) NOT NULL,
-			CHANGE1 float NOT NULL,
-			PRIMARY KEY (SYMBOL));
-
-CREATE TABLE IF NOT EXISTS HOLDING(
-			PURCHASEPRICE decimal(12, 2) NULL,
-			HOLDINGID integer AUTO_INCREMENT NOT NULL,
-			QUANTITY float NOT NULL,
-			PURCHASEDATE datetime NULL,
-			ACCOUNT_ACCOUNTID int NULL,
-			QUOTE_SYMBOL varchar(250) NULL,
-			PRIMARY KEY (HOLDINGID));
-
-CREATE TABLE IF NOT EXISTS ORDERS(
-			ORDERFEE decimal(12, 2) NULL,
-			COMPLETIONDATE datetime NULL,
-			ORDERTYPE varchar(250) NULL,
-			ORDERSTATUS varchar(250) NULL,
-			PRICE decimal(12, 2) NULL,
-			QUANTITY float NOT NULL,
-			OPENDATE datetime NULL,
-			ORDERID integer AUTO_INCREMENT NOT NULL,
-			ACCOUNT_ACCOUNTID integer NULL,
-			QUOTE_SYMBOL varchar(250) NULL,
-			HOLDING_HOLDINGID integer NULL,
-			PRIMARY KEY (ORDERID));
-
-CREATE TABLE IF NOT EXISTS DBCONFIG(
-			DBNAME varchar(50) NOT NULL,
-			HOSTNAME varchar(50) NOT NULL,
-			PORT integer NOT NULL,
-			ACTIVE varchar(1) NOT NULL,
-			PRIMARY KEY (DBNAME));
-
-CREATE TABLE IF NOT EXISTS SERVICE(
-			SERVICENAME varchar(50) NOT NULL,
-			URL varchar(500) NOT NULL,
-			PRIMARY KEY (SERVICENAME));
-
-CREATE TABLE IF NOT EXISTS CLIENTTOBS(
-			CLIENT varchar(50) NOT NULL,
-			BS varchar(50) NOT NULL,
-			PRIMARY KEY (CLIENT));
-
-CREATE TABLE IF NOT EXISTS BSTOOPS(
-			BS varchar(50) NOT NULL,
-			OPS varchar(50) NOT NULL,
-			PRIMARY KEY (BS));
+CREATE TABLE IF NOT EXISTS account(
+			creationdate datetime NULL,
+			openbalance decimal(12, 2) NULL,
+			logoutcount integer NOT NULL,
+			balance decimal(12, 2) NULL,
+			accountid integer AUTO_INCREMENT NOT NULL,
+			lastlogin datetime NULL,
+			logincount integer NOT NULL,
+			profile_userid varchar(250) NULL,
+			PRIMARY KEY (accountid));
+
+CREATE TABLE IF NOT EXISTS accountprofile(
+			address varchar(250) NULL,
+			password varchar(250) NULL,
+			userid varchar(250) NOT NULL,
+			email varchar(250) NULL,
+			creditcard varchar(250) NULL,
+			fullname varchar(250) NULL,
+			PRIMARY KEY (userid));
+
+/* quote is a reserved word in MySQL. A word following a period in a qualified
+ * name is treated as an identifier.
+ *
+ * http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html
+ */
+CREATE TABLE IF NOT EXISTS stocktraderdb.quote(
+			low decimal(12, 2) NULL,
+			open1 decimal(12, 2) NULL,
+			volume float NOT NULL,
+			price decimal(12, 2) NULL,
+			high decimal(12, 2) NULL,
+			companyname varchar(250) NULL,
+			symbol varchar(250) NOT NULL,
+			change1 float NOT NULL,
+			PRIMARY KEY (symbol));
+
+CREATE TABLE IF NOT EXISTS holding(
+			purchaseprice decimal(12, 2) NULL,
+			holdingid integer AUTO_INCREMENT NOT NULL,
+			quantity float NOT NULL,
+			purchasedate datetime NULL,
+			account_accountid int NULL,
+			quote_symbol varchar(250) NULL,
+			PRIMARY KEY (holdingid));
+
+CREATE TABLE IF NOT EXISTS orders(
+			orderfee decimal(12, 2) NULL,
+			completiondate datetime NULL,
+			ordertype varchar(250) NULL,
+			orderstatus varchar(250) NULL,
+			price decimal(12, 2) NULL,
+			quantity float NOT NULL,
+			opendate datetime NULL,
+			orderid integer AUTO_INCREMENT NOT NULL,
+			account_accountid integer NULL,
+			quote_symbol varchar(250) NULL,
+			holding_holdingid integer NULL,
+			PRIMARY KEY (orderid));
+
+CREATE TABLE IF NOT EXISTS dbconfig(
+			dbname varchar(50) NOT NULL,
+			hostname varchar(50) NOT NULL,
+			port integer NOT NULL,
+			active varchar(1) NOT NULL,
+			PRIMARY KEY (dbname));
+
+CREATE TABLE IF NOT EXISTS service(
+			servicename varchar(50) NOT NULL,
+			url varchar(500) NOT NULL,
+			PRIMARY KEY (servicename));
+
+CREATE TABLE IF NOT EXISTS clienttobs(
+			client varchar(50) NOT NULL,
+			bs varchar(50) NOT NULL,
+			PRIMARY KEY (client));
+
+CREATE TABLE IF NOT EXISTS bstoops(
+			bs varchar(50) NOT NULL,
+			ops varchar(50) NOT NULL,
+			PRIMARY KEY (bs));
 



Mime
View raw message