Trying to include where statement in Mjoin PHP
Trying to include where statement in Mjoin PHP
Hello everyone, I am in the middle of trying to make it so that any soft deleted entries in the table I am joining into for data are excluded, but I am having quite a bit of grief with where to put the ->where()
statement. Refer to the working version without where clauses below
->join(
Mjoin::inst( $tables->storageUnitsTable )
->name( $containers )
->link( $containers.'.parentUnitID', $storageUnits.'.storageUnitID')
->fields(
Field::inst('storageUnitID')
)
)
->join(
Mjoin::inst( $tables->prototypeSerialsTable )
->name( $serializedParts )
->link( $serializedParts.'.storageUnitID', $serializedParts.'.storageUnitID')
->fields(
Field::inst('prototypeSerialNumber'),
Field::inst('isDeleted'),
)
)
->where( $storageUnits.'.isDeleted', 0)
Both fields have the same soft delete flag isDeleted
, but whenever I put the where clause inside the Mjoin or join statements it keeps throwing errors. Any idea on how to make this work?
Thank you
Answers
What is the error please? I would have expected that to work.
Allan
So, the code shown above works a charm, but when I try to introduce
where()
to not include any soft deleted records in the join, it displays an error. For example:produces the following error message:
DataTables warning: table id=storageUnitsList - An SQL error occurred: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'serialized.isDeleted' in 'where clause'
I don't understand why it doesn't acknowledge the column when I do so, my first thought is it might be tied to the fact that I am aliasing the tables with
name()
, but even with that removed It does not want to play nice and I am at a loss for what to do to make it so that it recognizes theisDeleted
soft delete flag and prevents any data that should be inaccessible from being joinedCan you show me the SQL schema for these tables please? Specifically I'd like to see the structure of the
serialized
table.Also, could you add
->debug(true)
immediately before the->process(...)
call, and then show me the raw JSON that is returned from the server when you load the page?Thanks,
Allan