Problem with the where condition which is not taken into account
Problem with the where condition which is not taken into account
Hello,
I have a problem with this code which runs fine but the conditions where not taken into account.
I tried multiple solutions. Always the same result.
product.supp is INT
product.archive is INT
I want to exclude all rows that are 1 for either
<?php
// DataTables PHP library
include( "../Editor-PHP-1.9.1/lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;
Editor::inst( $db, 'produit_prix' )
->field(
Field::inst( 'produit_prix.produit_id' )
->options( Options::inst()
->table( 'produit' )
->value( 'id' )
->label( 'produit' )
)
->validator( Validate::dbValues() ),
Field::inst( 'produit_prix.prix' ),
Field::inst( 'produit_prix.saison' ),
Field::inst( 'produit_prix.last_update')
->setValue( date('c') )
->getFormatter( 'Format::date_sql_to_format', 'jS F Y' ),
Field::inst( 'produit.produit' ),
Field::inst( 'produit.supp' ),
Field::inst( 'produit.archive' )
)
->leftJoin('produit', 'produit.id', '=', 'produit_prix.produit_id')
->where('produit.supp', '1', '!=' )
->where('produit.archive', '1', '!=' )
->process($_POST)
->json();
Answers
That looks like it should be okay. Could you add
->debug(true)
immediately before the->process($_POST)
call, and then use the debugger to upload a trace for me please? When you update the trace it will give you a unique code - if you could send me that please.Thanks,
Allan
p.s. If you are using Editor 1.9.1 PHP files, as the path name suggests, update to 1.9.6 (the latest in the 1.x series) or 2.0.6 (the current release), just in case you are hitting an old bug somewhere (although none spring to mind that would effect that).
Allan
I updated to version 1.9.6, same problem.
Here is the debug
Many thanks. That shows the WHERE condition being applied to the SQL that is being executed.
Can you upload a debug trace or give me a link to your page so I can check it out please?
Allan
upload a debug trace??? I don't know how to do it, sorry.
Here is the link to test the page.
http://www.agrocropsmanager.fr/acm/gest_prix_produit.php
Thk Allan
Thanks for the link - that really helps!
I'm getting an error when I load the page about DataTables not being able to load valid JSON.
The response from the server contains:
Allan
Sorry, I forgot an argument. It's functional
Hello,
Have you seen anything?
Thanks
Sorry - I missed your previous reply. I'm now getting the following response from the server:
Allan
Sorry, I made the update and I forgot to change the link in the script
Is this working now? I just tried (created a record for season 1970) and it appears to be behaving. If not, please let us know,
Colin
No, it doesn't work. When I go back to the select menu there are entries that should not be there because I have excluded in the where the archive at 1 and supp at 1 but it does not take into account.
Example: the product Bolero if finds 2 while only one should appear. And ALF, OPAC etc...
Many thanks for updating the site.
This is the condition on the query that is being run:
Where the bindings are both 1. That seems to correspond with the data that is being returned, where
supp
andarchive
are both 0 for at least the first few records:Are there any records being loaded in where that condition is not being applied? Perhaps the issue is that the condition is not correct for the data you want to load?
Allan
Hello
I want
SELECT * from produit where archive = 0 AND supp = 0
Example SQL table
ID;product;cat;archive;supp
9407;ALF;Fertilizer;0;1
9417;ALF;Fertilizer;1;1
9317;ALF;Fertilizer;1;0
9413;ALF;oligos;0;0
Result
ID;product;cat;archive;supp
9413;ALF;oligos;0;0
Will produce that kind of query.
Allan