Select all fields where fieldone is not equal to null + Propel

nielsv picture nielsv · Aug 24, 2013 · Viewed 10.9k times · Source

I have a question about using the propel ORM and creating a query.

I have a table "locations" with fields:

  • location
  • sublocation
  • postcode
  • street
  • number

Now I want to select all the locations where the location field IS NOT equal to 'null'.
How can I do this? I've tried this but I get back all the results ...

Tried query: $locations = LocationQuery::create()->where('location' != null)->find();

Answer

user2707631 picture user2707631 · Jan 17, 2014

You can use this:

->filterByColumnName(null, Criteria::NOT_EQUAL) 

There are various 'Criteria' uses in propel, listed here: propel criteria

There isn't an exact sample for this on the site, the closest is this:

->filterByTags(array('novel', 'russian'), Criteria::CONTAINS_NONE)