插入子句出错:'字段列表'中的未知列'$ variableName'

时间:2015-08-31 04:14:23

标签: php sql

编辑:在阅读我不正确的SQL知识之前阅读以下答案lol

所以我试图插入一个变量,由于某种原因它认为它是一个列,即使我用单引号。我究竟做错了什么?谢谢你的时间。

Unknown column '$emailAddress' in 'field list'] in EXECUTE("UPDATE mailer_recipients SET email_address=$emailAddress WHERE id=539")

$sql = 'UPDATE ' . $this->recipientDbTable . ' SET ' . $this->recipientDbColumn['result_id'] . '=' . '$hash' . ' WHERE ' . $this->recipientDbColumn['id'] . '=' . $this->emailId;

    $sql = 'UPDATE ' . $this->recipientDbTable . ' SET ' . $this->recipientDbColumn['address'] . '=' . '$emailAddress' . ' WHERE ' . $this->recipientDbColumn['id'] . '=' . $this->emailId;

1 个答案:

答案 0 :(得分:2)

试试这个:

from django.db import models
try:
    from meeting.models import Meeting
    has_meetings = True
except:
    has_meetings = False

# Create your models here.


class Agenda(models.Model):
    name = models.CharField(max_length=255)
    if has_meetings:
        meeting = models.ForeignKey(Meeting, on_delete=models.PROTECT)
    priority = models.IntegerField()

阅读单引号和双引号之间的区别。