Using a MySQL Query to populate the Grid

QuestionsUsing a MySQL Query to populate the Grid
Tony Wolsey asked 6 years ago

Hello

Apologies if this has has been answered before, but is it possible to utilize a MySQL query to populate the grid columns rather than using a table?

If so, what is the code/syntax to implement this?

thank you

Tony

3 Answers
Abu Ghufran Staff answered 6 years ago
_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Tony Wolsey answered 6 years ago

thanks Abu but I did not see what I was looking for in the link you posted. Perhaps I missed it.

I was wondering if the PHP file can be linked to a MySQL query already created in the backend rather than a table.

//connect to a query

// set database table for CRUD operations

$g->table = “somequery“;  //?

_________________________________________

//instead of a table

// set database table for CRUD operations

$g->table = “clients”;

 

thanks

Tony

Abu Ghufran Staff answered 6 years ago

Pasting from docs:

By default, when we define the ->table property, it fetches all the possible columns of table. We can provide custom SQL query in ->select_command property to pick columns available for grid. We can use complex multi-join sub-queries in it.

$g->select_command = “SELECT i.id, invdate , c.name,
i.note, i.total, i.closed FROM invheader i
INNER JOIN clients c ON c.client_id = i.client_id”;

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

5 + 15 =

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?