php - In Propel2, filter crossref by null value -


i use propel2 orm.

i've 2 tables entry , category connected many-to-many relationship via entrycategory table.

i set iscrossref on true in schema.xml.

everything works fine : i'm able filter entry category :

entryquery::create()->filterbycategory($cat) 

but

i'm not able filter entries with no category. tried

entryquery::create()->filterbycategory(null, criteria::equal) 

or

entryquery::create()->filterbycategory(null, criteria::isnull) 

but, gives me

'filterbycategory() accepts arguments of type \category or collection' 

i tried

entryquery::create()->where('category null') 

but, i've got error

unknown column 'category' in 'where clause' 

so, need ...

edit :

extract of schema.xml :

<?xml version="1.0" encoding="utf-8"?> <database package="core" name="bank" identifierquoting="true" defaultidmethod="native" defaultphpnamingmethod="underscore">   <table name="category" idmethod="native" phpname="category">     <column name="id" phpname="id" type="integer" size="5" primarykey="true" autoincrement="true" required="true"/>     <column name="name" phpname="name" type="varchar" size="50" required="true"/>     <column name="parent_id" phpname="parentid" type="integer" size="5"/>     <foreign-key foreigntable="category" phpname="parent">       <reference local="parent_id" foreign="id"/>     </foreign-key>     <index name="parent_id">       <index-column name="parent_id" size="5"/>     </index>     <vendor type="mysql">       <parameter name="engine" value="innodb"/>     </vendor>   </table>   <table name="entry" idmethod="native" phpname="entry">     <column name="id" phpname="id" type="integer" primarykey="true" autoincrement="true" required="true"/>     <column name="account_id" phpname="accountid" type="integer" required="true"/>     <column name="date" phpname="date" type="date" required="true"/>     <column name="entry" phpname="entry" type="varchar" size="255" required="true"/>     <column name="type" phpname="type" type="integer" size="2"/>     <column name="amount" phpname="amount" type="decimal" size="12" scale="2" required="true"/>     <index name="account">       <index-column name="account_id"/>     </index>     <index name="md5">       <index-column name="md5" size="32"/>     </index>     <index name="md5_2">       <index-column name="md5" size="32"/>       <index-column name="account_id"/>     </index>     <foreign-key foreigntable="account">       <reference local="account_id" foreign="id"/>     </foreign-key>     <vendor type="mysql">       <parameter name="engine" value="innodb"/>     </vendor>   </table>   <table name="entry_category" idmethod="native" phpname="entrycategory" iscrossref="true">     <column name="entry_id" phpname="entryid" type="integer" primarykey="true" required="true"/>     <column name="category_id" phpname="categoryid" type="integer" size="5" primarykey="true" required="true"/>     <foreign-key foreigntable="entry" name="entry_category_ibfk_1">       <reference local="entry_id" foreign="id"/>     </foreign-key>     <foreign-key foreigntable="category" name="entry_category_ibfk_2">       <reference local="category_id" foreign="id"/>     </foreign-key>     <index name="category_id">       <index-column name="category_id" size="5"/>     </index>     <vendor type="mysql">       <parameter name="engine" value="innodb"/>     </vendor>   </table> </database> 

you need use id or name or whatever column name is.

->filterbycategory expects propel object of category type.
->filterbycategoryid() or whatever name actual column is. (having schema beneficial)

not passing sets null. else handled string literal. where column = 'null'


use either ->filterbycategory() (if name of column , not foreign key reference) or ->filterbycategoryid() if 'categoryid' 'phpname' of column.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -