我的第一个问题是:
$sql = "UPDATE application SET userid = ? WHERE appid = ? LIMIT 1";
我的第二个疑问是:
SELECT user.name,application.appid,application.userid,application.created,application.title,application.filesize,application.status,application.apptype
FROM user,application
WHERE application.appid = ? LIMIT 1
然后使用$statement->fetchObject()
问题是$statement->name
总是bob
。 application.userid
是表userid
中user
的外键。如果我更改表userid
中的application
,请说10
,查询2应该从新user
上的表userid
中获取名称,但是问题是,它一直告诉我$statement->name
是bob
。
if (isset($_POST['newowner']))
{
$newowner = $_POST['newowner'];
$sql = "SELECT COUNT(*) FROM user
WHERE userid = ? LIMIT 1";
$statement = $db->prepare($sql);
$statement->execute(array($newowner));
if ($statement->fetchColumn() > 0)
{
$sql = "UPDATE application SET userid = ?
WHERE appid = ? LIMIT 1";
$statement = $db->prepare($sql);
$statement->execute(array($newowner,$_GET['appid']));
$appdetail->msg = "Owners were successfully changed.";
$appdetail->type = "success";
}
else
{
$appdetail->msg = "Could not find client by that userid or email.";
$appdetail->type = "warning";
}
}
$sql = "SELECT user.name,application.appid,application.userid,application.created,application.title,application.filesize,application.status,application.apptype
FROM user,application
WHERE application.appid = ? LIMIT 1";
$statement = $db->prepare($sql);
$statement->execute(array($_GET['appid']));
$app = $statement->fetchObject();