S
S
Sasha Brahms2015-12-10 20:50:30
PHP
Sasha Brahms, 2015-12-10 20:50:30

Response, Request in MVC?

What do the Request and Response classes do?
Response is more clear, set headers and the like, but Request ?
Can you give a description and an example of how this works?
otherwise I got lost, I absolutely can’t find and understand why all this, I will be very grateful)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Miku Hatsune, 2015-12-10
@Dlike

For example, convenient access to _POST, _GET, _COOKIE, etc.
There are data filters, conveniently encapsulated...etc.
Read this: https://docs.phalconphp.com/ru/latest/api/Phalcon_...
For example:

// Если запрос был методом POST и через AJAX. Не правда ли просто и удобно?
if ($this->request->isPost() AND $this->request->isAjax()) 
{
    $name = $this->request->getPost('name'); // нет необходимости проерять существование индекса
    $password = $this->request->getPost('password');

    $user = new Models/Users();
    $user->name = $name;
    $user->password = $password;

    if ($user->save())
    {
        echo 'Успешно';
    }
    else
    {
        echo 'Fail';
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question