where data in object - join - edit
where data in object - join - edit
RafaelGarcia
Posts: 20Questions: 1Answers: 0
in Editor
as I can do a "-> where ()" of an object after a join,
eg $ out = $ editor -> where ('table1.table_id', '1', '=') -> process ($ _ POST) -> data ();
Echo json_encode ($ out);
table1 is the result of a -> join
This discussion has been closed.
Replies
I'm not sure what your question is? That looks like it should work okay.
Allan
comprehensive information and copy the code to make it more real. generates an error message.
```php
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tms_fallas.falla_nombre' in 'where clause'' in /var/www/tms/php/lib/Database/Driver/Mysql/Query.php:98
<?php
/*
* Editor server script for DB table tms_slots
* Automatically generated by http://editor.datatables.net/generator
*/
// DataTables PHP library
include( "lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
$editor = Editor::inst( $db,'tms_novedades','novedad_id')
$out = $editor ->where('tms_fallas.falla_nombre','carlos paz')->process($_POST) ->data();
<?php > ``` ?>echo json_encode( $out );
the idea is that each user only change the assigned fields according to their city, so wanted to use "where" to filter them according to the case.
I'm doing wrong !!!
thanks for help
The error message is saying that there is no column in the table called
tms_fallas.falla_nombre
.Allan
when he used works perfect
$out = $editor ->where('novedad_estado','cerrada')->process($_POST) ->data();
echo json_encode( $out );
{"id":-1,"error":"","fieldErrors":[],"data":[],"aaData":[{"DT_RowId":"row_1","novedad_fechaInicio":"2015-02-05 09:24:34","novedad_fechaCierre":"0000-00-00 00:00:00","novedad_estado":"cerrada","novedad_id":"1","tms_fallas":{"falla_id":"1","falla_nombre":"bloqueo juego","falla_icon":"<i title=\"fuera de servicio\" class=\"splashy-error\"><\/i>"},"tms_slots":{"slot_id":"1","slot_numeroCetsa":"A-2500","slot_numeroOnline":"22500","slot_numeroSerie":"DX010214V"}}]}
when used as follows, and error does not work.
the tms_fallas table exists and falla_nombre culmna there.
$out = $editor ->where('tms_fallas.falla_nombre','bloqueo juego')->process($_POST) ->data();
echo json_encode( $out );
I'm doing wrong !!! thanks for help
will be the version I am using?
thanks for help
Are you still getting the same error message when you use
where('tms_fallas.falla_nombre','bloqueo juego')
? The error message states that a column by that name doesn't exist. Perhaps there is a typo?Allan
allan,
the problem is that the column is the result of a join table with a link !!!! and when 'tms_fallas.falla_nombre' use gives me the error but if use 'novedad_fechaInicio' works well.
'tms_novedades' is the name of a table and 'novedad_fechaInicio' is the name of a column.
'tms_fallas' is a table name and 'falla_nombre' is the name of a column.
'tms_novedades_fallas' is the link table.
thanks for help
I see the issue now - thanks for the explanation.
So the problem is that you are applying the
where
condition to the editor top level table, but the join is a separate query as you have it set up at the moment.What I would suggest is that you use a
leftJoin
rather than theJoin
class since you are only using a one-to-one join (i.e. objects).Then you will be able to apply the
where
expression to the main Editor.The alternative is to apply the
where
to yourJoin
instance which will reduce the result set of that join (NOT the overall data set) to just that option. Which might be what you want...Allan
Reproduce your suggestion and it worked
thanks for help