Mark Fondy
Mark Fondy

Reputation: 3923

Propel - where and begins

I have table:

Article:
ID | TITLE | CONTENT
1  | aaa+s | sdsd
2  | ccc+a | sdsda
3  | aaa+s | dsdsd
4  | aaa+2 | sfsdf
5  | sds+2 | sadasds

How to get all Article where title begins of aaa+ ?

           $c = new Criteria();
           $c->add(ArticlePeer::TITLE, ????);
           $art = ArticlePeer::doSelectOne($c);  

Upvotes: 1

Views: 348

Answers (1)

Tamer Shlash
Tamer Shlash

Reputation: 9523

as a plain MySQL statement:

       SELECT * FROM `Article` WHERE TITLE LIKE "aaa+%"

In Symfony, it can be done this way:

       $c = new Criteria();
       $c->add(ArticlePeer::TITLE, 'aaa+%', Criteria::LIKE);
       $art = ArticlePeer::doSelectOne($c);  

Check out here table 8 -1 for more details.

Upvotes: 5

Related Questions