D
D
dzhuryn_volodymyr2015-10-02 15:32:03
PHP
dzhuryn_volodymyr, 2015-10-02 15:32:03

Whether it is possible to connect here limit through the Prepared expressions?

$sql = "select R.id,R.uri,R.pagetitle,R.content,
              (select $TVR.value from $TVR where $TVR.tmplvarid=142 and $TVR.contentid=R.id limit 1) as poster
            FROM $R AS R
            JOIN  $TVR ON R.id=$TVR.contentid
            JOIN  $MUC ON R.id=$MUC.contentid
            WHERE published=1 and deleted=0 and template IN(97,108) and tmplvarid=170 and $TVR.value like ?
            ORDER BY $MUC.createdon desc
            LIMIT $sqlLimitStart,$itemsPage ";
    $q = $modx->prepare($sql);
    $q->execute(array($like));
    $res = $q->fetchAll(PDO::FETCH_ASSOC);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivanq, 2015-10-02
@Ivanq

Yes.
Or I didn't understand the question?

A
Aleksey Ratnikov, 2015-10-22
@mahoho

Add named placeholders: LIMIT :offset, :limit, and then bind the parameter as a number:
But in this case, all parameters should be bound like this, and $stmt->execute() should be left empty.
php.net/manual/en/pdostatement.bindvalue.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question