Fatal error: Uncaught exception 'Phalcon\Mvc\Model\Exception' with message 'Syntax error,

Fatal error: Uncaught exception 'Phalcon\Mvc\Model\Exception' with message 'Syntax error, unexpected token >, near to ' LIMIT :APL0:', when parsing: SELECT [Multiple\Backend\Models\urunler].* FROM [Multiple\Backend\Models\urunler] WHERE urunNo => LIMIT :APL0: (111)' in C:\xampp\htdocs\BestShop\apps\backend\models\urunler.php:42 Stack trace: #0 [internal function]: Phalcon\Mvc\Model\Query->parse() #1 [internal function]: Phalcon\Mvc\Model\Query->execute() #2 C:\xampp\htdocs\BestShop\apps\backend\models\urunler.php(42): Phalcon\Mvc\Model::findFirst(Array) #3 C:\xampp\htdocs\BestShop\apps\backend\controllers\UrunController.php(56): Multiple\Backend\Models\urunler->sil(NULL) #4 [internal function]: Multiple\Backend\Controllers\UrunController->silAction('125') #5 [internal function]: Phalcon\Dispatcher->dispatch() #6 C:\xampp\htdocs\BestShop\public\index.php(98): Phalcon\Mvc\Application->handle() #7 C:\xampp\htdocs\BestShop\public\index.php(105): Application->main() #8 {main} thrown in C:\xampp\htdocs\BestShop\apps\backend\models\urunler.php on line 42

Model

    public function delete($id){
        $product = products::findFirst(
                array(
                        "conditions" =>"urunId => $id"
                ));
        $product->delete($id);
    }

Controller

    public function deleteAction(){
       $product = new products();
       $product->delete($this->request->getPost('id'));
    }

View

    <td>{{ link_to("admin/product/delete/" ~ detay.urunId, 'Delete') }}</td>



30.7k

Hi,

you have to use parameters bindings: https://docs.phalconphp.com/en/latest/reference/models.html#binding-parameters

public function delete($id){
    $product = products::findFirst(
            array(
                    "conditions" =>"urunId = :id:",
                    "bind" => array("id"=> $id)
            ));
    $product->delete($id);
}


2.3k

Fatal error: Call to a member function delete() on boolean in ???

$product->delete($id);



30.7k

make sure that your query returns a valid object ( var_dump($product) ).

I think, that your query didn't mach any record