Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
emrullahayin opened this issue Oct 26, 2015 · 6 comments
Labels
not a bug Reported issue is not a bug

Comments

@emrullahayin
Copy link

emrullahayin commented Oct 26, 2015

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()
#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 sil($id){

        $urun = urunler::findFirst(
                array(
                        "conditions" =>"urunNo => $id"
                ));
        $urun->delete($id);

    }

Controller

  public function silAction(){
    $urun = new urunler();
    $urun->sil($this->request->getPost('id'));
}
@emrullahayin emrullahayin changed the title Notice: Array to string conversion in C:\xampp\htdocs.. ??????? Fatal error: Uncaught exception 'Phalcon\Mvc\Model\Exception' with message 'Syntax error, Oct 26, 2015
@ashpumpkin
Copy link
Contributor

try

public function sil($id){

    $urun = urunler::findFirst(
            array(
                    "urunNo = :id:",
                    "bind" => ['id' => $id]
            ));
    $urun->delete($id);

}

or

public function sil($id){
 $urun = urunler::findFirst($id); // urunNo must be PK
    $urun->delete($id);
}

or

public function sil($id){

    $urun = urunler::findFirst(
            array(
                    "urunNo = $id"
            ));
    $urun->delete($id);

}

@emrullahayin
Copy link
Author

I do not want to delete the record

@SidRoberts
Copy link
Contributor

There's an error in the model. The conditions property needs to be an SQL-like string and the bind property is an associative array of variables. More information available here.

This should work:

public function sil($id){
    $urun = urunler::findFirst(
            array(
                    "conditions" => "urunNo = :urunNo:",
                    "bind"       => ["urunNo" => $id]
            ));
    $urun->delete($id);
}

@rianorie
Copy link
Contributor

I actually think he was trying to find all records where urunNo is equal to or higher than, which is ">=" and not "=>"

@equivaQstu
Copy link

I received this error after unintentionally creating a duplicate endpoint in routes.php. I had two identical POST paths each with a different corresponding function. I was using a Micro app. I'm not sure if the error was coming from
$app->setRoutes($routes);
or
$app->run();
Deleting the duplicate path in my routes.cfg cleared the error.

@sergeyklay sergeyklay added the not a bug Reported issue is not a bug label May 13, 2016
@sergeyklay
Copy link
Contributor

Phalcon Query Language (PHQL)


For questions like this you can use forum: https://forum.phalconphp.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug Reported issue is not a bug
Projects
None yet
Development

No branches or pull requests

6 participants