Using a MySQL Query to populate the Grid

QuestionsUsing a MySQL Query to populate the Grid
Tony Wolsey asked 3 weeks 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 3 weeks ago
_________________________
Abu Ghufran - Dev Team
PHP Grid Framework
 
Tony Wolsey answered 3 weeks 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 3 weeks 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
PHP Grid Framework
 
Your Answer

17 + 6 =

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 / 5. Vote count:

As you found this post useful...

Follow us on social media!

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

Let us improve this post!