> Hi all!
>
> I want to select data (from PostgreSQL) from an view like this:
>
> $this->allSqlResult = $this->sqlEntity->fetchAll(
> $this->sqlEntity->select()->where(
> $this->sayCMSGridSession->{$this->sayCMSSession->pageName}->where
> . ' = ? ',
> '%' .
> $this->sayCMSGridSession->{$this->sayCMSSession->pageName}->where_value
> . '%'));
>
> And the result is nothing. I watched the logs and I found this:
>
> SELECT "saycms_modules_movieslibrary_view_movies".* FROM
> "saycms_modules_movieslibrary_view_movies" WHERE (title= '%kutya%' )
>
> and the result is really nothing because I want to see after the
> "WHERE" an beautiful "title LIKE('%kutya%')".
>
> So, my question is the next:
> Can I select data through Zend_Db_Table_Abstract with LIKE? Did I
> something wrong? Should I use Zend_Db_Select? What is yours
> suggestions?
>
> Appreciate your help!
>
> Thank you!
>
> András
>
I think, you'd have to something like.
$db->where('field like ?', "%{$var}%");
I'm not exactly sure though -- dump the query before you execute it
and see if it renders the SQL you expect. Aside from that -- is LIKE
supported by Postgres? I'd double-check that as well. And also,
whatever Postgres uses for wildcards, e.g. %.
Hope that helps,
Till
没有评论:
发表评论