hi Milooz,

you must define explicitely a primary key inside the schema.xml... if you
dont't, propel will take to do that automatically by adding a default
primary key called 'ID'... then, you have troubles if the 'ID' field doesn't
exists into your database !

in your case, just indicate : 'primaryKey: true' for the appropriate field
of your table.

for instance :

  oid:
     type: INTEGER
     required: true
     autoIncrement: true
     primaryKey: true

Hadrien

2007/5/14, Milooz <[EMAIL PROTECTED]>:
>
>
> Hi,
>
> I have to translate an old existing web site to a Symfony project.
> It's my first project using Symfony framework.
> The database is already existing.
> I used propel-build-schema to generate the schema.yml file.
> I have a lot of different table but for now i focus on the Article
> table.
>
> My problem is that the schema.yml file looks good, i see all the
> existing fields and not more but in the BaseArticle.php and
> BaseArticlePeer.php files i have a new fields (Property of the
> classes) at end, respectively called
> protected $id;
> and
> const ID = 'article.ID';
>
> so when i try to make a custom query using this function:
>   public static function getRecentArticle()
>   {
>     $c = new Criteria();
>     $c->add(ArticlePeer::STATUS, 'published');
>     $c->add(ArticlePeer::NEWS, '1');
>     $c->add(ArticlePeer::TOPIC_OID, '10');
>     $c->addDescendingOrderByColumn(ArticlePeer::CREATION);
>     $c->setLimit(1);
>     $article = ArticlePeer::doSelect($c);
>     return ($article);
>   }
>
> i receive this exception:
>
> [wrapped: Could not execute query [Native Error: Unknown column
> 'article.ID' in 'field list'] [User Info: SELECT article.OID,
> article.CREATION, article.TITLE, article.BODY_RAW, article.BODY_HTML,
> article.AUTHOR_NAME, article.AUTHOR_EMAIL, article.TOPIC_OID,
> article.STATUS, article.LETTER_OID, article.NEWS, article.GAMES,
> article.MOBILES, article.CHANNEL, article.MANAGER, article.LVN,
> article.HIFI, article.SECTOR_OID, article.THEME_OID,
> article.MOBILES_OID, article.GAMES_OID, article.MANAGER_OID,
> article.MANAGERC_OID, article.LVN_OID, article.MOTS_CLEFS,
> article.SOCIT, article.ID FROM article WHERE
> article.STATUS='published' AND article.NEWS=1 AND article.TOPIC_OID=10
> ORDER BY article.CREATION DESC LIMIT 1]]
>
> i will make a more specific query only on few fields, i hope it will
> pass,
> but i'd like to know how to resolve this problem.
>
> Thanks in advance.
>
> You can find here a part of schema.yml file :
>   article:
>     _attributes:
>       idMethod: native
>     oid:
>       type: INTEGER
>       required: true
>       autoIncrement: true
>     creation:
>       type: TIMESTAMP
>       required: true
>       default: 0000-00-00 00:00:00
>     title:
>       type: LONGVARCHAR
>     body_raw:
>       type: LONGVARCHAR
>     body_html:
>       type: LONGVARCHAR
>     author_name:
>       type: VARCHAR
>       size: 100
>       required: true
>       default:
>     author_email:
>       type: VARCHAR
>       size: 100
>       required: true
>       default:
>     topic_oid:
>       type: INTEGER
>       required: true
>       default: 0
>     status:
>       type: CHAR
>       required: true
>       default: draft
>     letter_oid:
>       type: INTEGER
>       required: true
>       default: 99
>     news:
>       type: TINYINT
>       required: true
>       default: 0
>     games:
>       type: TINYINT
>       required: true
>       default: 0
>     mobiles:
>       type: TINYINT
>       required: true
>       default: 0
>     channel:
>       type: TINYINT
>       required: true
>       default: 0
>     manager:
>       type: TINYINT
>       required: true
>       default: 0
>     lvn:
>       type: TINYINT
>       required: true
>       default: 0
>     hifi:
>       type: TINYINT
>       required: true
>       default: 0
>     sector_oid:
>       type: INTEGER
>       required: true
>       default: 0
>     theme_oid:
>       type: INTEGER
>       required: true
>       default: 0
>     mobiles_oid:
>       type: INTEGER
>       required: true
>       default: 0
>     games_oid:
>       type: INTEGER
>       required: true
>       default: 0
>     manager_oid:
>       type: INTEGER
>       required: true
>       default: 0
>     managerc_oid:
>       type: INTEGER
>       required: true
>       default: 0
>     lvn_oid:
>       type: INTEGER
>       required: true
>       default: 0
>     mots_clefs:
>       type: VARCHAR
>       size: 255
>       required: true
>       default:
>     socit:
>       type: VARCHAR
>       size: 255
>       required: true
>       default:
>     _indexes:
>       oid:
>         - oid
>       topic_oid:
>         - topic_oid
>       creation:
>         - creation
>       author_name:
>         - author_name
>       news:
>         - news
>         - games
>         - mobiles
>         - channel
>         - manager
>         - lvn
>         - hifi
>       lvn_oid:
>         - lvn_oid
>       fulltext:
>         - title
>         - body_html
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to