Keyur | |
I was checking sql log for one of our grid, and it seems that koolgrid is doing select count(*)(my sql query) and then doing select * (my sql query) which does hammer mysql sometimes. So i was thinking is you guys can just do the select * (query passed my user) and then do sizeof(sql result) it might improve the grid performance and less burden on mysql.
Posted Aug 14, 2015
Kool
|
|
David | |
Thanks Keyur for your suggestion!
Indeed, the second query is "SELECT * from ($selectcommand) $where $orderby $groupby $limit" to retrieve data for only one page of the grid so sizeof would return the grid's page size. Anyway, we will try to optimize our data source for the future releases. Rgds,
Posted Aug 14, 2015
Kool
|
|
Keyur | |
Thank for reply David,
Also in the KoolGrid Changelog it says "Release AdvancedPDODataSource.php" but there is no documentation on how to implement the PDO connection for Grid.
Posted Aug 14, 2015
Kool
|
|
David | |
Hi Keyur,
Just create a PDO connection to your database and use that connection to create a PDODataSource instance. Manual for creating a PDO can be referenced here: http://php.net/manual/en/pdo.connections.php Rgds,
Posted Aug 15, 2015
Kool - 1 person likes this post
|
|
Keyur | |
Hi David,
In KoolGrid/ext/datasources/PDODataSource.php which i got from koolphp suite, I found this example at top of the file: //*************************************************************************************** // Example: // ... // $ds = new PDODataSource(new PDO ("mssql:host=localhost;dbname=mydatabase","username","password")); // $ds->SelectCommand = "SELECT * FROM customers"; // ... // $grid->MasterTable->DataSource = $ds; // ... //*************************************************************************************** and i implemented it in my code like below: $ds_product = new PDODataSource($pdoObj->connect()); Where connect() is method of my PDO class helper with connection code : $this->_db = new PDO("$this->_dbType:host=$this->_dbHost;dbname=$this->_dbDatabase", $this->_dbUsername, $this->_dbPassword); and it returns the connection object. But when i use PDO connection in KoolGrid i am getting this error saying "Fatal error: Class 'PDODataSource' not found in /mnt/hgfs/Projects/webs/webroot/iec/htdocs/app/views/products/edit_product_price.ctp on line 875" which refers to this line "$ds_product = new PDODataSource($pdoObj->connect());". So i don't know if KoolGrid is not including the PDODataSource.php file with it. Please let me know if there is other way to do it.
Posted Aug 17, 2015
Kool
|
|
David | |
Hi Keyur,
KoolGrid contains the standard MySQLDataSource class. For other database classes please includes the files in the folder KoolControls/KoolGrid/ext/datasources. There you could find PDODataSource.php. Rgds,
Posted Aug 18, 2015
Kool
|
|