Modify the original DV SQL
Modify the original DV SQL
Hello,
How can I modify the SQL statement of a detail view to add an additional search where condition?
I don't want to use filters because the user can remove them and I need him not to have access to other records
The option to access their own records does not help me because the user is not always who creates their records
Thank you
How can I modify the SQL statement of a detail view to add an additional search where condition?
I don't want to use filters because the user can remove them and I need him not to have access to other records
The option to access their own records does not help me because the user is not always who creates their records
Thank you
Re: Modify the original DV SQL
Do you really mean "detail view"? Or do you want to restrict the visible records in table-view?
Maybe you can do additional auth checks in _dv function of hooks/TABLENAME.php and perhaps redirect the user conditionally.
Best
Jan
Maybe you can do additional auth checks in _dv function of hooks/TABLENAME.php and perhaps redirect the user conditionally.
Best
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Modify the original DV SQL
Sorry, the Table View
I need to modify the Query to add a Where condition!!!
Regards
I need to modify the Query to add a Where condition!!!
Regards
Re: Modify the original DV SQL
Hi,
you can use the TABLENAME_init function.
add:
you can use the TABLENAME_init function.
add:
Code: Select all
$options->QueryWhere="where YOUR CLAUSE";
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Modify the original DV SQL
Thanks
In which file I include the option?
Regards
In which file I include the option?
Regards
Re: Modify the original DV SQL
in the hooks/TABLENAME.php file
where TABLENAME is the table where you want to apply the where clause to the sql query.
where TABLENAME is the table where you want to apply the where clause to the sql query.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Modify the original DV SQL
Sorry, It's not working
This is my test code:
function Pagos_init(&$options, $memberInfo, &$args){
$options->QueryWhere="WHERE Casa = 30";
return TRUE;
}
and I get nothing, if I run the statment:
Select * from Pagos WHERE Casa = 30
I got records
Regards
This is my test code:
function Pagos_init(&$options, $memberInfo, &$args){
$options->QueryWhere="WHERE Casa = 30";
return TRUE;
}
and I get nothing, if I run the statment:
Select * from Pagos WHERE Casa = 30
I got records
Regards
Re: Modify the original DV SQL
Hi,
maybe you need to check if there is already a where statement for that table. In that case you would need
$options->QueryWhere=" AND Casa = 30";
maybe you need to check if there is already a where statement for that table. In that case you would need
$options->QueryWhere=" AND Casa = 30";
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Modify the original DV SQL
Hi,
I already tried it but it doesn't work
Is there any way to see the SQL statement which is sent, in order to see how complete the SQL statement?
Thank you
I already tried it but it doesn't work
Is there any way to see the SQL statement which is sent, in order to see how complete the SQL statement?
Thank you
Re: Modify the original DV SQL
try to add this in the init part. you shall see the $option parameters
ob_start();
$xc=get_object_vars($options);
ksort($xc);
print_r($xc);
$c=ob_get_clean();
echo "<pre>".htmlspecialchars($c)."</pre>";
ob_start();
$xc=get_object_vars($options);
ksort($xc);
print_r($xc);
$c=ob_get_clean();
echo "<pre>".htmlspecialchars($c)."</pre>";
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Modify the original DV SQL
Thanks
The information I obtain before including the statement is:
[QueryWhere] =>
And after including the statement is:
[QueryWhere] => Casa = 30
But I still get the error that no records are found
The information does not show me the SQL statement to know how the request for records is being made
Best regards
The information I obtain before including the statement is:
[QueryWhere] =>
And after including the statement is:
[QueryWhere] => Casa = 30
But I still get the error that no records are found
The information does not show me the SQL statement to know how the request for records is being made
Best regards
Re: Modify the original DV SQL
Hi ,
you need to add the "WHERE " string as well.
So after changing the QueryWhere should show:
[QueryWhere] => WHERE Casa = 30
you need to add the "WHERE " string as well.
So after changing the QueryWhere should show:
[QueryWhere] => WHERE Casa = 30
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Modify the original DV SQL
Now I get this, but still without records
[QueryWhere] => WHERE Casa = 30
Regards
[QueryWhere] => WHERE Casa = 30
Regards
Re: Modify the original DV SQL
hmmm, that is strange.
is it possible that you post all the Query fields?
is it possible that you post all the Query fields?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Modify the original DV SQL
Thanks, I could fix it with this:
$options->QueryWhere=" WHERE `Pagos`.`Casa` = 30";
It's working
Best regards
$options->QueryWhere=" WHERE `Pagos`.`Casa` = 30";
It's working
Best regards
Re: Modify the original DV SQL
Hi Cesteban,
Did you manage to get your WHERE clause in the [QueryWhere] => hook to work with standard Appgini filters?
I am trying to achieve a similar thing as you but I can manage to get filters to work when the WHERE clause is applied?
See here: viewtopic.php?f=2&p=11686#p11654
Any advice/help welcome. Thanks.
Did you manage to get your WHERE clause in the [QueryWhere] => hook to work with standard Appgini filters?
I am trying to achieve a similar thing as you but I can manage to get filters to work when the WHERE clause is applied?
See here: viewtopic.php?f=2&p=11686#p11654
Any advice/help welcome. Thanks.