Google App Engine处理PHP和MySQL的方式有何不同?我正在尝试将一个非常简单的应用程序从GoDaddy移植到Google App Engine和Google Cloud SQL。我花了2天时间阅读,尝试,重新编码,我无法弄清楚这一点。每次我触发PHP文件而不是在2个不同的表中创建1条记录时,它会在每个表中创建2条记录,其中某些列的值为空(绝对不允许使用空值)。
它在GoDaddy上运行得很完美,并且在Google Cloud SQL上创造了无关的记录?
<?php
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$servername = "ipinfo";
$dbconn = new PDO('mysql:unix_socket=/cloudsql/connectinfo',
'root', // username
'' // password
);
$phone = $_REQUEST['From'];
$message = addslashes($_REQUEST['Body']);
$convoSQL = "SELECT id FROM smsConversation WHERE phone=$phone AND closed='0' order by timestamp desc;";
$info = $dbconn->query($convoSQL);
foreach ($info as $row) {
$openConversation = $row['id'];
}
if($row == false){
$newConvoQuery = "INSERT INTO smsConversation (phone) values ('$phone');";
$dbconn->query($newConvoQuery);
$openConversation = $dbconn->lastInsertId();;
}
$sql = "INSERT INTO smsMessage (phone,message,conversation_id) values ('$phone','$message','$openConversation');";
$dbconn->exec($sql);
echo "<Response>";
echo '<Sms to="+mynumber">You have a new text from ' . $phone . ' saying ' . $message . '</Sms>';
echo "</Response>";