更新查询不会更新我的产品列表

时间:2015-06-24 17:47:23

标签: php mysql sql

我的产品详细信息没有更新,我遇到严重问题。它在我单击编辑时获取所有产品信息,但是当我按下提交按钮更新产品详细信息时,它对数据库没有影响。我花了很长时间在这上面,并且也在线查看解决方案。他们似乎都没有工作

这是我的代码:

#!/bin/bash

# Set some variables

export site_path=~/Documents/Blog
drafts_path=~/Documents/Blog/_drafts
title="$title"

# Create the filename

title=$("$title" | "awk {print tolower($0)}")
filename="$title.markdown"
file_path="$drafts_path/$filename"
echo "File path: $file_path"

# Create the file, Add metadata fields

cat >"$file_path" <<EOL
---
title: \"$title\"
layout: 
tags: 
---
EOL

# Open the file in BBEdit

bbedit "$file_path"

exit 0

1 个答案:

答案 0 :(得分:0)

您正在使用PDO和准备好的声明。您无法将带有变量值的现成SQL查询提供给PDO::prepare。引用the manual中的示例:

$sth = $dbh->prepare('SELECT name, colour, calories
    FROM fruit
    WHERE calories < ? AND colour = ?');

$sth->execute(array(150, 'red'));

您传递到PDO::execute的数组会替换每个数组吗?使用数组中值的值。否则,您可以传入关联数组并使用命名参数执行此操作:

$sql = 'SELECT name, colour, calories
    FROM fruit
    WHERE calories < :calories AND colour = :colour';

$sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));

$sth->execute(array(':calories' => 150, ':colour' => 'red'));