multiple custom queries

Questionsmultiple custom queries
Qasim Khan asked 9 years ago

Hi,
how can we use multiple customize query, E.g there is default query
$g->select_command = "select * from table;
there is dropdown menu on the page which has options to count the records like, toyota,honda,ford, etc…
when user select an option (honda) we run the qurey as
select COUNT(*) from cars where model = 'honda';
now grid show all records related to model(honda) and count of records. how can we use customize query while default query is still there. Thanks.

3 Answers
Abu Ghufran answered 9 years ago

You can use GET form method, and use $_GET data condition in select_command. e.g.

if ($_GET["brand")
$g->select_command = "select * from table WHERE brand = {$_GET['brand']}";
else
$g->select_command = "select * from table";

Qasim Khan answered 9 years ago

Abu Ghufran,
i have used it but there is no record. if i statically assign value to variable like below.

$dat = "honda";
$g->select_command ="SELECT * FROM tablename where model = '$dat'";

there is long error dialog box which contain my raw table data. data is not showing in grid.

Abu Ghufran answered 9 years ago

It looks like there are some print/echo statements before $g->render() function.
Make sure you call '$g->render();' function before any HTML is rendered

Your Answer

18 + 1 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?