This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.2 » doctrine - strange Doctrine_Connection_Mysql_Exception
doctrine - strange Doctrine_Connection_Mysql_Exception [message #73982] Tue, 03 March 2009 21:58 Go to next message
elmoby  is currently offline elmoby
Messages: 3
Registered: March 2009
Location: Barcelona
Junior Member
Hi!!

doctrine is givving me a strange error related with the generator.yml.

I have defined the generator.yml as follows:

--------------------------------------------------------
generator:
class: sfDoctrineGenerator
param:
model_class: Programacion
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: programacion_programacion
with_doctrine_route: 1

config:
actions: ~
fields: ~
list:
title: Lista de tareas
display: [letter, lista, is_activated, task_at]
max_per_page: 10
object_actions:
queue_add: { label: Queue add, action: queueAdd }
queue_send: { label: Queue send, action: queueSend }
_edit: ~
_delete: ~
sort: [letter, asc]
filter:
display: [is_activated]
form: ~
edit: ~
new: ~
--------------------------------------------------------

Whey I try to enter to this page in the backend, propel is creating wrongly the query:

at Doctrine_Connection->execute('SELECT p.id AS .... p__letter_id FROM programacion p ORDER BY p.letter_id asc asc LIMIT 4', array())

The error comes at the end where it says: asc asc.
Y have tryed many things such as changing to desc, clearing the cache, etc, but it keeps saying asc asc.

I'm a newbe in symfony ... could ypu please help me? Txs. Dan
Re: doctrine - strange Doctrine_Connection_Mysql_Exception [message #96973 is a reply to message #73982 ] Thu, 08 April 2010 16:58 Go to previous messageGo to next message
old_thrashbarg  is currently offline old_thrashbarg
Messages: 3
Registered: March 2010
Junior Member
Well, about one year later and using symfony 1.4 I've run into the same error and can't find a solution.

I'm using the following two tables, declared in schema.yml:

UserGroups:
  tableName: user_groups
  columns:
    id:
      type: integer(2)
      unsigned: true
      primary: true
      autoincrement: true
    name:
      type: string(48)
      notnull: true
    manager_user_id:
      type: integer(4)
      unsigned: true
  indexes:
    idx_name:
      fields: [name]
      type: unique
  relations:
    Users:
      local: manager_user_id
      foreign: id
      type: one
    Users_2:
      class: Users
      local: group_id
      foreign: user_id
      refClass: UsersInGroups

Users:
  tableName: users
  columns:
    id:
      type: integer(4)
      unsigned: true
      primary: true
      autoincrement: true
    nickname:
      type: string(24)
      notnull: true
    password:
      type: string(128)
      notnull: true
    firstname:
      type: string(64)
      notnull: true
    lastname:
      type: string(64)
      notnull: true
    email:
      type: string(64)
      notnull: true
    status:
      type: integer(1)
      unsigned: true
      notnull: true
      default: 0
    last_login: timestamp(25)
    last_login_ip: integer(8)
    created_at: timestamp(25)
    updated_at: timestamp(25)
  indexes:
    idxEmailUnique:
      fields: [email]
      type: unique
  relations:
    UserGroups:
      local: id
      foreign: manager_user_id
      type: many
    UserGroups_2:
      class: UserGroups
      local: user_id
      foreign: group_id
      refClass: UsersInGroups

UsersInGroups:
  tableName: users_in_groups
  columns:
    group_id:
      type: integer(2)
      unsigned: true
      primary: true
    user_id:
      type: integer(4)
      unsigned: true
      primary: true


In the generated admin interface for the UserGroups I get the following error, when I open the list view:

Doctrine_Connection_Mysql_Exception:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'asc LIMIT 20' at line 1. Failing Query: "SELECT u.id AS u__id, u.name AS u__name, u.manager_user_id AS u__manager_user_id FROM user_groups u ORDER BY u.name asc asc LIMIT 20"

My generator.yml looks like this:
generator:
  class: sfDoctrineGenerator
  param:
    model_class:           UserGroups
    theme:                 admin
    non_verbose_templates: true
    with_show:             false
    singular:              group
    plural:                groups
    route_prefix:          groups
    with_doctrine_route:   true
    actions_base_class:    sfActions

    config:
      actions: ~
      fields:
        manager_user_id: { label: Manager }
        users_in_groups: { label: User }
      list:
        title: Gruppen-Verwaltung
        display: [=name, _manager_user_id, _users_in_groups]
        object_actions:
          _edit:   { label: Bearbeiten }
          _delete: { label: Löschen }
          erase:
            label: Ausradieren
            help: Gruppe und alle Mitglieder darin löschen
            params:
              confirm: Sind Sie ganz sicher (Mitglieder werden mit gelöscht)
        batch_actions:
          _delete: { label: Löschen }
          erase:
            label: Ausradieren
            params:
              confirm: Sind Sie ganz sicher (Mitglieder werden mit gelöscht)
      filter:
        class: false
      form:
        class: AdminUserGroupsForm
      edit:
        title: Gruppe bearbeiten
        actions:
          _list:          ~
          _save:          ~
      new:
        title: Neue Gruppe


What I'm irritated about is there being a sort order at all. When I tried to give a predefined sort-order (manager_user_id DESC) in generator.yml, this was ignored in the query.
After some hours of search I couldn't find the reason for that (to me strange) behaviour ...

With desperate greetings
old_thrashbarg
Re: doctrine - strange Doctrine_Connection_Mysql_Exception [message #97015 is a reply to message #96973 ] Fri, 09 April 2010 09:53 Go to previous messageGo to next message
old_thrashbarg  is currently offline old_thrashbarg
Messages: 3
Registered: March 2010
Junior Member
Hello,

here I'm again, trying to explain the solution I've found after having a night of good sleep ...

The fault was all mine !!!

But maybe, someone runs into the same trap, so here is what I did wrong:

Somewhere in the run of development I tried to give a default sorting in the generator.yml and added the following (don't try this, the error came from using a wrong syntax):
      list:
        sort: name asc

When I then, already on the right path to find the error, cut off the line giving the predefined sort, symfony always threw the same error again, because the sorting is saved in the user related data and reused, now overriding the default sorting !
So switching to the correct syntax didn't get me rid of the error ...
I therefore implemented my own ->getSort() method in class "groupsActions", overriding the one in base-class "autoGroupsActions", only to discard the user-sorting and force the usage of (now correct) default sorting. After that everything worked fine and I could throw away the overriding ->getSort()

And last of all:
The correct syntax of giving a default sort-order is that of an array:
      list:
        sort: [name, asc]

as mentioned in the manual ...

P.S.:
If someone wants to copy-paste the ->getSort() to get back to the right path:
class groupsActions extends autoGroupsActions
{
  // all the other stuff here ...

  protected function getSort()
  {
    $this->setSort($this->configuration->getDefaultSort());
    return $this->getUser()->getAttribute('groups.sort', null, 'admin_module');
  }
}
Re: doctrine - strange Doctrine_Connection_Mysql_Exception [message #101961 is a reply to message #97015 ] Sun, 04 July 2010 06:07 Go to previous message
nicolardi  is currently offline nicolardi
Messages: 1
Registered: July 2010
Location: Italy
Junior Member
I had the same problem as your, I have a little comment about this:

Quote:

When I then, already on the right path to find the error, cut off the line giving the predefined sort, symfony always threw the same error again, because the sorting is saved in the user related data and reused, now overriding the default sorting !
So switching to the correct syntax didn't get me rid of the error ...
I therefore implemented my own ->getSort() method in class "groupsActions", overriding the one in base-class "autoGroupsActions", only to discard the user-sorting and force the usage of (now correct) default sorting. After that everything worked fine and I could throw away the overriding ->getSort()


I noticed that the sorting is stored in the user session so when you change the user datayou can clear the browser cookies and relogin.

The default sorting comes back again.

Bye,
Massimo
Previous Topic:[Solved] Only save ONE of my EmbeddedForm
Next Topic:How to use database for configurations
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software