![]() |
#2
yusinging2015-06-04 15:49
附上我的php(跑不出)
<?php //not on Saturday and Sunday if(date("w",time())==0)exit; if(date("w",time())==6)exit; //chdir('/home/gurufocu/public_html/Vera'); //include "../include/config.php"; //include "../include/financial_functions.php"; //include_once ("../db_functions.php"); //$db_stock = connect_stockdb(); //$db_data = connect_datadb(); //echo "\ntest\n"; $db_stock_dev = connect_stockdb(); $db_data_dev = connect_datadb_dev(); $date_today=date("Y-m-d"); echo "\n$date_today\n"; $date=date_create($date_today); date_add($date,date_interval_create_from_date_string("+30 days")); $date_new=date_format($date,"Y-m-d"); echo "\n$date_new\n"; //exit; $sql="SELECT * FROM gurufocu_main.`inst_holdings` where filling_type in ('13D', 'SC 13D/A', 'SC 13D', '13D/A') and symbol!='' and portdate<'$date_new' and verified=1 order by portdate desc limit 0,1"; $result=mysql_query($sql, $db_stock_dev); $nrows = mysql_num_rows($result); echo "\n$nrows\n"; //loop one-to-one if($nrows!= 0){ for($j1=0;$j1<$nrows;$j1++){ $row = mysql_fetch_assoc($result); $symbol=$row['symbol']; $exchange=$row['exchange']; $guru_id=$row['guru_id']; $portdate=$row['portdate']; //secr_id $sql_sec="SELECT a.morn_secr_id FROM gurufocu_main.stock_list as a where a.exchange='$exchange' and symbol='$symbol'"; echo $sql_price; $result_sec=mysql_query($sql_sec,$db_stock_dev); $nrows_sec = mysql_num_rows($result_sec); if($nrows_sec != 0){ $row_sec = mysql_fetch_assoc($result_sec); $morn_secr_id=$row_sec['morn_secr_id']; } echo "\n$morn_secr_id\n"; $date_1=date_create($portdate); date_add($date_1,date_interval_create_from_date_string("31 days")); $date_30d=date_format($date_1,"Y-m-d"); $sql_sec="SELECT b.close FROM gurufocu_data.price_all as b and gurufocu_main.stock_list as a where b.sec=a.morn_secr_id'"; echo $sql_price; $result_sec=mysql_query($sql_sec,$db_stock_dev); $nrows_sec = mysql_num_rows($result_sec); if($nrows_sec != 0){ $row_sec = mysql_fetch_assoc($result_sec); $close=$row_sec['close']; } echo "\n$close\n"; } } ?> |
本菜坐标上海,再做一份美国数据库的实习。结果从MySQLWorkBench的连接开始就有很多问题了!目前这个程序最核心的问题是有三张不在一个数据库的表格需要合并,目前写出来的是
SELECT a.exchange,a.symbol,b.close, b.date, c.portdate FROM price_all as b, stock_list_morningstar as a, inst_holdings as c where b.sec=a.morn_secr_id and c.portdate=b.date;
感觉不太对,求大神指教。顺便求坐标上海的大神面基,只需要教教SQL和php就行,学费好商量,请吃饭。谢谢!