Reference to Multiple Databases *

* Please note this feature is only available in paid versions.

phpGrid nows supports data source from more than one database on a single page. Simply use the 4th parameter in constructor (C_DataGrid) to overwrite the initial database settings in conf.php.

In the following example, grid A binds a table from one database, while grid B binds another table from a completely different database, all on the same page.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$gridA = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
$gridA->enable_edit("INLINE","CRUD");
$gridA -> display();

// overwrite database settings with another database.
$gridB = new C_DataGrid("SELECT * FROM names", "id", "names",
                        array("hostname"=>"localhost",
                            "username"=>"USER2",
                            "password"=>"PASSWORD",
                            "dbname"=>"utf8db",
                            "dbtype"=>"mysql",
                            "dbcharset"=>"utf8"));

$gridB->enable_edit("INLINE","CRUD");
$gridB -> display();

See Live Example!

No related content found.

Tags: ,