Reputation: 67888
I am a beginner and I am creating some forms to be posted into MySQL using Zend, and I am in the process of debugging but I don't really know how to debug anything using Zend. I want to submit the form and see if my custom forms are concatenating the data properly before it goes into MySQL, so I want to catch the post data to see a few things. How can I do this?
Upvotes: 0
Views: 4102
Reputation: 112
You can check post data by using zend
$request->isPost()
and for retrieving post data
$request->getPost()
For example
if ($request->isPost()) {
$postData = $request->getPost();
Zend_Debug::dump($postData );
}
Upvotes: 0
Reputation: 804
Zend framework is built on the top of the PHP . so you can use var_dump($_POST) to check the post variables.
ZF has provided its own functions to get all the post variables.. Zend_Debug::dump($this->getRequest()->getPost())
or specifically for one variable.. you can use Zend_Debug::dump($this->getRequest()->getPost($key))
Upvotes: 0
Reputation: 16455
The Default route for zend framework application looks like the following
http://www.name.tld/$controller/$action/$param1/$value1/.../$paramX/$valueX
So all $_GET-Parameters simply get contenated onto the url in the above manner /param/value
Let's say you are within IndexController
and indexAction()
in here you call a form. Now there's possible two things happening:
IndexController:indexAction()
$form->setAction('/index/process')
in that case you would end up at IndexController:processAction()
The way to access the Params is already defined above. Whereas $this->_getParam()
equals $this->getRequest()->getParam()
and $this->_getAllParams()
equals $this->getRequest->getParams()
The right way yo check data of Zend Stuff is using Zend_Debug as @vascowhite has pointed out. If you want to see the final Query-String (in case you're manually building queries), then you can simply put in the insert variable into Zend_Debug::dump()
Upvotes: 5
Reputation: 18440
The easiest way to check variables in Zend Framework is to use Zend_Debug::dump($variable);
so you can do this:-
Zend_Debug::dump($_POST);
Upvotes: 2
Reputation: 5115
you can use $this->_getAllParams();
.
For example: var_dump($this->_getAllParams()); die;
will output all the parameters ZF received and halt the execution of the script. To be used in your receiving Action.
Also, $this->_getParam("param name");
will get a specific parameter from the request.
Upvotes: 3