Home › Forums › Guriddo Suito PHP › Suito PHP and ZF1 integration through Zend_Db_Adapter_Pdo_Mysql
Time ago I ask if this library support Zend Framework 1 because we want to buy it but in order to do that I need to demonstrate my boss that it works as should be. So this is what I am testing currently:
|
1 2 3 4 5 6 7 8 9 |
dbOptions = $config->db->config->toArray(); $dbOptions['driver_options'] = array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true); $dbAdapter = Zend_Db::factory($config->db->adapter, $dbOptions); Zend_Db_Table::setDefaultAdapter($dbAdapter); Zend_Registry::set('dbAdapter', $dbAdapter); $adapter = Zend_Registry::get('dbAdapter'); |
From the code above $adapter turns on a Zend_Db_Adapter_Pdo_Mysql. Which is PDO but if I try to do the following:
|
1 2 3 |
$grid = new jqGridRender($adapter); |
My code thrown the following error:
PHP Fatal error: Call to undefined method Zend_Db_Adapter_Pdo_Mysql::setAttribute() in /var/www/library/PHPSuito/jqGrid.php(1) : eval()’d code on line 1
I am not sure how to integrate the library and Zend Framework so I’ll need some support. We still interested in buy the library but we won’t do it unless I can demonstrate that is usable from a Zend Framework 1 project.
Can I get someone writing a small example for usage so I can test it in my own environment?
Hello,
As far as I remember our discussion was here.
In my post I note that we do not understand ZF1, but give you advice’s how to pass ZF1 connection to the jqGrid.
Now I will write it for second time:
1. To the grid we passed connection object.
2. If your adapter stores a PDO connection somewhere then you can easy pass it.
By example if you have:
|
1 2 3 4 5 6 7 8 |
... $dbAdapter = Zend_Db::factory($config->db->adapter, $dbOptions); Zend_Db_Table::setDefaultAdapter($dbAdapter); Zend_Registry::set('dbAdapter', $dbAdapter); $adapter = Zend_Registry::get('dbAdapter'); ... |
and your adapter stores the connection object to
$adapter->Connection , then you will need to pass this to the grid and not the adapter.
|
1 2 3 |
... $grid = new jqGridRender($adapter->Connection); ... |
Simple the reletion is this:
|
1 2 3 4 5 |
... $adapter->Connection = $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); ... |
Of course in ZF1 this should have another name and this is just example.
What you need to know is where the ZF1 stores this object in its adapter.
Hope it is now clear
Kind Regards,
Will
Guriddo Support Team
Hi there, I am getting an error when the grid is being render and I don’t know why or how to trace it. This is how my code looks like:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
public function indexAction() { $CODE_PATH = 'PHPSuito/'; require_once $CODE_PATH.'jqGrid.php'; require_once $CODE_PATH.'jqGridRender.php'; require_once $CODE_PATH.'DBdrivers/jqGridPdo.php'; $adapter = Zend_Registry::get('dbAdapter'); $grid = new jqGridRender($adapter->getConnection()); $grid->SelectCommand = 'SELECT * FROM companies'; $grid->dataType = 'json'; $grid->setColModel(); $grid_url = Zend_Controller_Front::getInstance()->getRequest()->getControllerName().'/'.Zend_Controller_Front::getInstance()->getRequest()->getActionName(); $grid->setUrl($grid_url); $grid->setGridOptions(array( "rownumbers" => true, "rownumWidth" => 35, "rowNum" => 10, "sortname" => "companies_id", "toppager" => true, "rowList" => array(10, 20, 50), )); $grid->setColProperty("companies_id", array("label" => "ID", "width" => 60)); $grid->setColProperty("created_date", array( "formatter" => "date", "formatoptions" => array("srcformat" => "Y-m-d H:i:s", "newformat" => "m/d/Y") ) ); $grid->navigator = true; $grid->setNavOptions( 'navigator', array("cloneToTop" => true, "add" => false, "edit" => false, "del" => false, "excel" => false) ); $grid->renderGrid('#grid', '#pager', true, null, null, true, true); } |
Then the JSON returned is something like:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
{ "records": "1", "page": 1, "total": 1, "rows": [ { "companies_id": "1", "parent_companies_id": "0", "client_of_companies_id": "0", "asset_locations_id": null, "companies_name": "container", "companies_number": "000001", "companies_url": "", "location_number": null, "statuses_id": "1", "managed": "0", "created_date": "0000-00-00 00:00:00", "created_by_users_id": "0", "updated_date": "2017-01-16 15:53:35", "updated_by_users_id": null, "host_companies_id": "0", "host_company": "0", "view_pricing": "1", "is_demo": "0", "expired_date": "0000-00-00", "companies_region_name": null, "companies_location_name": null, "companies_address1": null, "companies_address2": null, "companies_city": null, "companies_state_name": null, "companies_state_abbr": null, "companies_country_name": null, "companies_country_abbr": null, "companies_logo": "default.jpg", "companies_zip": null, "internal_name": null, "internal_number": null, "phone": null, "fax": null, "number_of_subcompanies": "0", "company_type": null, "companies_header": "default_header.jpg", "send_alert": "1", "create_asset": "1", "create_servicepak": "1", "create_contract": "1", "alert_section_1": null, "alert_section_2": null, "group_companies_id": "0", "email": null, "VAT": null, "CustomerSiteID": null, "DistributorID": null } ] } Can not write to log! |
What log is that? How I disable such feature? I don’t need to write anything
Ok, I’ve discovered how to fix the previous issue by setting:
|
1 2 3 |
$grid->logtofile = false; |
But the error still and I can see the following on the debug output:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
Array ( [0] => Array ( [time] => 2017-02-01 14:07:44 [query] => SELECT COUNT(*) AS COUNTR FROM companies [data] => [types] => [fields] => [primary] => [input] => ) [1] => Array ( [time] => 2017-02-01 14:07:44 [query] => SELECT * FROM companies ORDER BY companies_id asc LIMIT 0, 10 [data] => [types] => [fields] => [primary] => [input] => ) ) |
I am not sure what this means or what I’m missing, could you help?
What is the error reported?
Please show us the text reported as error!
Maybe you may need to disable debugging where you set it somewhere?
$grid->debug = false; // this option by default is false
Please check this option, or
set
$grid->logtofile = true
and make your directory writtable by the script.
Regards
Will
Guriddo Support Team
Hi, by setting:
$grid->logtofile = false;
the error above dissapear but I am still getting an issue. Check below:

Hello,
Please find and remove (or comment) any echo or print_r command which are connected to jqGrid script.
We are close.
Kind Regards
Will
Guriddo Support Team
There is not such thing on my code, what you’re seeing here is exactly what I currently have in my class
Hello,
This is strange. This message is lunched in the error ajax function.
This mean the the request is something wrong.
Could you please look in your browser console (Chrome or FireFox) the status of the request?
You can look more detailed for the error in the console and the response of the request.
Kind Regards,
Will
Guriddo Support Team
Hello,
There is not such thing on my code, what you’re seeing here is exactly what I currently have in my class
I’m not sure that this is true, since you have a ToolbarSearch mode which I do not see in your code.
Please check your code again!
Kind Regards,
Will
Guriddo Support Team
I can’t test anymore apparently, I got this “Script expired” message when I try to execute the code 🙁
Hello,
To get another period of testing, please re download the trial from our download page
Kind Regards,
Will
Guriddo Support Team
That’s exactly what I did but still not working :-\
Finally I have managed to make the library work and this is how the code looks like currently:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
public function indexAction() { $CODE_PATH = 'PHPSuito/'; require_once $CODE_PATH.'jqGrid.php'; require_once $CODE_PATH.'jqGridRender.php'; require_once $CODE_PATH.'DBdrivers/jqGridPdo.php'; $adapter = Zend_Registry::get('dbAdapter'); $grid = new jqGridRender($adapter->getConnection()); $grid->SelectCommand = 'SELECT * FROM companies'; $grid->dataType = 'json'; $grid->setColModel(); $grid_url = Zend_Controller_Front::getInstance()->getRequest()->getControllerName().'/'.Zend_Controller_Front::getInstance()->getRequest()->getActionName(); $grid->setUrl($grid_url); $grid->setGridOptions(array( "rownumbers" => true, "rownumWidth" => 35, "rowNum" => 10, "sortname" => "companies_id", "toppager" => true, "rowList" => array(10, 20, 50), )); $grid->setColProperty("companies_id", array("label" => "ID", "width" => 60)); $grid->setColProperty("created_date", array( "formatter" => "date", "formatoptions" => array("srcformat" => "Y-m-d H:i:s", "newformat" => "m/d/Y") ) ); $grid->navigator = true; $grid->setNavOptions( 'navigator', array("cloneToTop" => true, "add" => false, "edit" => false, "del" => false, "excel" => false) ); $grid->renderGrid('#grid', '#pager', true, null, null, true, true); } |
There is not “echo” or “print_f” or any other output statement around meaing the code you’re seeing here is the code being executed. The template is completely empty as well.
No matter what the error still happening and for some reason the response comes as a whole HTML page and not a JSON, why? no ideas!!
Any other clue or test you want me to perform?
Hello,
Glad to hear that the problem is solved.
One possible reason that can cause this problem is a white space in the file.
Kind Regards,
Will
Guriddo Support Team
Hi there, I think you miss understand => “Finally I have managed to make the library work” this mean I didn’t get the “Script expired” message but I can’t get this to work, the same issue where the JSON is printed out to a popup window still happening so nothing is really fixed I am still need some support to make this work otherwise my boss won’t never buy something that doesn’t work with our system.
Thanks
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top