我正在尝试使用开源项目Authpuppy中使用的数据库上的DQL查询来更新表,该项目使用了doctrine 1.2和symfony 1.4,
我正在尝试执行以下Doctrine更新查询,
$q = Doctrine_Query::create()
->update('Connection')
->set('status', 'LOGGED_OUT')
->where('token = ?', $fields['token']);
$q->execute();
它给出了错误:
Doctrine_Connection_Mysql_Exception
以下是Schema.yml,
Connection:
tableName: connections
actAs: [Timestampable]
columns:
node_id:
type: integer
notnull: true
token:
type: string(255)
unique: true
notnull: true
status:
type: string(255)
notnull: true
mac:
type: string(255)
ip:
type: string(255)
auth_type:
type: string(255)
identity:
type: string(255)
incoming:
type: float
default: 0
outgoing:
type: float
default: 0
relations:
Node:
class: Node
local: node_id
foreign: id
type: one
onDelete: CASCADE
options:
symfony:
form: false
filter: false
model: false
答案 0 :(得分:3)
我解决了这个问题。感谢Marc B
$q = Doctrine_Query::create()
->update('Connection')
->set('status', '?', 'LOGGED_OUT') //Here is the change
->where('token = ?', $fields['token']);
$q->execute();