How to search in two table Dynamically PHP ? I've two tables .. say users table and books table I wanna make search in both but I wanna write the code once dynamically . understand which table should look in and what fields should use to search.
Any Ideas ?
@ebrahemsamer ,
Do you mean if you don't find result in 1st table you will look in the 2nd table ?
no the application will know which table to search in . @psylogic
Is this pure php or laravel?
@sinnbeck Pure PHP, I want an idea..
also two tables have different fields.... and different rules for search
Well if it is just the logic, you could perhaps make each param start with the table name and then extract it from the string
http://website.com? table1_name=john&table2_age=44&table2_position=manager
foreach ($requestparameters as $key =>$param) {
$arr= implode('_', $key);
$search[$arr[0]][$arr[1]] = $param;
}
Please sign in or create an account to participate in this conversation.