Problems with filtering in select tag

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
josecnp1
User
Posts: 73

Problems with filtering in select tag

Post by josecnp1 »

I have created a filter through a table view in mysql
And works correctly when using in edit tag in select
after in lookup table I filled the fields well
When I add or edit in the table the filter works correctly
The problem is that the same filter acts on the list and view pages
How would you use the filter in the edit pages and add pages?

I tried using this code in Recordset Selecting event but it does not work

if ($fld->FldName == "n_taquilla" and CurrentPageID() == "add") {
ew_AddFilter($filter, "id_llave = (SELECT id_llave FROM v_ubicacion_llave) ");
}
if ($fld->FldName == "n_taquilla" and CurrentPageID() == "edit") {
ew_AddFilter($filter, "id_llave = (SELECT id_llave FROM v_ubicacion_llave) ");
}

This is the view that I created to make a previous filter and give the results that I want

CREATE VIEW vista_llaves AS select distinct v_ubicacion_llave.id_llave AS id_llave,v_ubicacion_llave.id_ubicacion AS id_ubicacion,v_ubicacion_llave.n_taquilla AS n_taquilla,v_ubicacion_llave.llave AS llave from v_ubicacion_llave where (not(exists(select taquillas.n_taquilla from taquillas where (taquillas.n_taquilla = v_ubicacion_llave.id_llave))));


mobhar
User
Posts: 11711

Post by mobhar »

It depends on your needs. What value would you like to assign to "id_llave" field in that string filter?

Try change:
ew_AddFilter($filter, "id_llave = (SELECT id_llave FROM v_ubicacion_llave) ");

to (assume you have already had value of "something" in "id_llave" field):
ew_AddFilter($filter, "id_llave = 'something'");


josecnp1
User
Posts: 73

Post by josecnp1 »

I have finally used the filter in Lookup Selecting event

if ($fld->FldName == "n_taquilla" and CurrentPageID() == "edit") {
ew_AddFilter($filter, "id_llave = (SELECT id_llave FROM v_ubicacion_llave) ");
}

But I get this error: Error (1242): Subquery returns more than 1 row

What I need is that in the selection use all the values that in the subquery


mobhar
User
Posts: 11711

Post by mobhar »

Change:
SELECT

to:
SELECT DISTINCT


Post Reply