Notice: Array to string conversion in ????

Model

public function sil($id){
    $urun = urunler::findFirst(
            array(
                    "conditions" =>"urunId => $id"
            ));
    $urun->delete($id);
}

Controller

public function deleteAction(){
    $urun =  new urunler();
    $urun->sil($this->request->getPost());
}

Hey, you did not specify key in getPost()

Try like so:

$this->request->getPost('id')


2.3k

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('117') #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

edited Oct '15

You can simply do:

public function sil($id){
    $urun = urunler::findFirst($id);
    $urun->delete();
}


2.3k

I want to delete, select the record ?? How to?

edited Oct '15

Your model:

public function sil($id){
    $urun = urunler::findFirst($id);
    $urun->delete();
}

Your controller:

public function deleteAction(){
    $urun =  new urunler();
    $urun->sil($this->request->getPost('id')); // $urun->sil($this->request->get('id'));
}

getPost('id') or get('id') depending on how you pass the id to the deleteAction method.



2.3k

This is first delete record the table. I want to record you want to delete

HOW? :)



2.3k

<td width="7%">{{ link_to("admin/urun/delete/" ~ detay.urunId, 'Delete') }}</td>

This finds the first record with the primary key = $Id

findFirst($id)

Judging by your volt template, your controller should be:

$urun->sil($this->request->get('id')); Or whatever you named the parameter in your routes.


2.3k

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>