1
votes

I am trying to update table using DQL query on database used in open source project Authpuppy which uses doctrine 1.2 and symfony 1.4,

I am trying to execute following Doctrine Update Query,

$q = Doctrine_Query::create()
    ->update('Connection')
    ->set('status', 'LOGGED_OUT')
    ->where('token = ?', $fields['token']);

    $q->execute();

It Gives Error:

Doctrine_Connection_Mysql_Exception

Following is the 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
1
catch the exception and use whatever doctrine's methods are to examine the ACTUAL error message to find out what's wrong...Marc B
It says Unknown column LOGGED_OUTStraw Hat
should be ->set('status', '?', 'LOGGED_OUT') arg1: field to update, arg2: placeholder/function, arg3: actual value. you're literally trying to do update ... set status=LOGGED_OUT as isMarc B
Great!! It worked. I am new to doctrine.Straw Hat
@MarcB I have added it as answerStraw Hat

1 Answers

3
votes

I solved this question. Thanks to Marc B

$q = Doctrine_Query::create()
    ->update('Connection')
    ->set('status', '?', 'LOGGED_OUT')   //Here is the change
    ->where('token = ?', $fields['token']);

    $q->execute();