Call controller/action/model/field

Hi,

i have a link;

index/tags&tags=flowers

And i want to

SELECT * FROM index WHERE tags LIKE %flowers%

This is my function in IndexController:

public function tagsAction(){

    $currentPage = (int) $_GET["page"];
    $tagsVar = $_GET["tags"];

    $findTags = Index::find(
        array(
            'tags IN (?0)',
            'bind' => array(
                $tagsVar
            )
        )
    );



    $paginator = new Paginator(array(
        "data" => $findTags,
        "limit" => 96,
        "page" => $currentPage
    ));

    $this->view->setVar('page', $paginator->getPaginate());

}

The result should be the parameter for the paginator.

Thx

Rgds

Stefan

And what is the exact issue you are having? php $this->view->setVar('page', $paginator->getPaginate()); is empty?

BTW, you should not use $_GET superglobal, use Phalcon's methods from Request component.



19.4k

Hello stamster,

the message i get, is that the column flowers doesn't exists. I will copy the text at the evening.

Ok i will use Phalcons methods :-)

Rgds

Stefan

Don't ever use $_GET !



19.4k

Hi Wojciech Ślawski,

i found the $_GET in our docu: https://docs.phalconphp.com/en/latest/reference/pagination.html

Maybe that must be changed.

Rgds

Stefan

edited May '16

This is just example, you see in it:

// Current page to show
// In a controller this can be:
// $this->request->getQuery('page', 'int'); // GET
// $this->request->getPost('page', 'int'); // POST

We could perhaps change can to should.

Offtopic: in this case using plain $_GET is not that much of a trouble, since that value is passed to be bound with PDO, thus it is assumed that value is unsafe.



19.4k

Here we go, my message:

Scanning error before 'flowers)' when parsing: SELECT [Vokuro\Models\Index].* FROM [Vokuro\Models\Index] WHERE tags IN (?flowers) (82
edited May '16
$findTags = Index::find(
        array(
            'tags IN (?0)',
            'bind' => array(
                $tagsVar
            )
        )
    );
What is this code ? Why you just can't:
        $findTags = Index::find(
        array(
            'tags LIKE :flowers:',
            'bind' => array(
                'flowers'=>$tagsVar
            )
        )
    );


19.4k

Hi Wojciech Ślawski,

i found something like that in the forum :-/

But now i have a blank page. What is this code generated?

SELECT * from `index` where `tags` like '%flowers%'

Rgds

Stefan

That means you have exception, check logs ?



19.4k

Hello Wojciech Ślawski,

i tried the whole evening, can't get it run.

i have also tried with FlowersController and view, always blank page, also with raw sql.

in phpmyadmin sql box i get 2000 results.

Do you have another idea?

Rgds Stefan

As i wrote, check logs, blank page means you have exception.