-4

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>
HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47

1 Answers1

0
public function delete($id){
    $product = products::findFirst([
                "conditions" =>"urunId = $id"
            ]
    $product->delete($id);
}
  • Fatal error: Call to a member function delete() on boolean in ??? $product->delete($id); – Phalconphp Oct 26 '15 at 09:43
  • 1
    If you examine the query result, it will probably be a false. If you read the source code, you will see that false gets returned when no such tuple/model exists. public function delete($id) { $product = products::findFirst([ "conditions" => "urunId = $id" ] ); if (!$product){ // do stuff, fx: // 1) throw new \Exception('No such model in our db') // 2) return false // 3) OR however else u wanna handle it } $product->delete($id); } – Nikos Papageorgiou Oct 26 '15 at 13:29
  • 1
    Also its a good idea to keep your classes with capital first letter, and in singular, e.g.: Product::findFirst(); – Nikos Papageorgiou Oct 26 '15 at 13:31
  • I do not want to delete the record – Phalconphp Oct 27 '15 at 09:02
  • 1
    Why to model delete function in model, where Phalcon already offers it? You Have syntax error spoted by Niranjan. You should use `'bind'` opt – yergo Oct 27 '15 at 12:14