Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is DBAL returning a SQL Syntax Error?
    primarykey
    data
    text
    <p>I'm using Doctrine 2 along with CodeIgniter.</p> <p>I'm having a query in some of my functions that trigger a SQL Error. And I can't find the reason why</p> <p>The function is the following:</p> <pre><code>private function _key_exists($key) { $this-&gt;CI-&gt;load-&gt;library('doctrine'); $em = $this-&gt;CI-&gt;doctrine-&gt;em; echo "&lt;br /&gt;Key : ".$key; $key_object = $em-&gt;getRepository( 'Entity\Key' )-&gt;findOneBy( array( 'key' =&gt; $key ) ); if( $key_object ) { return TRUE; } else { return FALSE; } // return $this-&gt;db-&gt;where(config_item('rest_key_column'), $key)-&gt;count_all_results(config_item('rest_keys_table')) &gt; 0; } </code></pre> <p>When Key ENtity is :</p> <pre><code>&lt;?php namespace Entity; use Doctrine\ORM\Mapping as ORM; /** * Keys * * @ORM\Table(name="keys") * @ORM\Entity */ class Key { /** * @var integer * * @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** * @var string * * @ORM\Column(name="key", type="string", length=40, precision=0, scale=0, nullable=false, unique=false) */ private $key; /** * @var integer * * @ORM\Column(name="level", type="integer", precision=0, scale=0, nullable=false, unique=false) */ private $level; /** * @var boolean * * @ORM\Column(name="ignore_limits", type="boolean", precision=0, scale=0, nullable=false, unique=false) */ private $ignoreLimits; /** * @var boolean * * @ORM\Column(name="is_private_key", type="boolean", precision=0, scale=0, nullable=false, unique=false) */ private $isPrivateKey; /** * @var string * * @ORM\Column(name="ip_addresses", type="text", precision=0, scale=0, nullable=true, unique=false) */ private $ipAddresses; /** * @var integer * * @ORM\Column(name="date_created", type="integer", precision=0, scale=0, nullable=false, unique=false) */ private $dateCreated; /* Getters and Setters ... */ } </code></pre> <p>And the error message is :</p> <blockquote> <p>Doctrine\DBAL\DBALException: An exception occurred while executing 'SELECT t0.id AS id1, t0.key AS key2, t0.level AS level3, t0.ignore_limits AS ignore_limits4, t0.is_private_key AS is_private_key5, t0.ip_addresses AS ip_addresses6, t0.date_created AS date_created7 FROM keys t0 WHERE t0.key = ? LIMIT 1' with params {"1":"0fedfa4d50653317df76a4dba79f9f07cd7a8273"}: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'keys t0 WHERE t0.key = '0fedfa4d50653317df76a4dba79f9f07cd7a8273' LIMIT 1' at line 1 in E:\Programmes\wamp\www\myapp\application\libraries\Doctrine\DBAL\DBALException.php on line 47</p> </blockquote> <p>I do see : <code>Key : c242c67787bd0b9a9b11a54fc942fde50f099235</code> in the output though</p> <p>Many thanks for your help</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload