title: Cakephp SQLSTATE[42000]: Syntax error or access violation: 1064
body: <p>I got this error:</p>
  
  <blockquote>
    <p>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 'set_origin' at
    line 1</p>
  </blockquote>
  
  <p>this error occur when I add this line in my OrderItems controller.</p>
  
  <pre><code>$products = $this-&gt;OrderItem-&gt;Product-&gt;find('all');
  </code></pre>
  
  <p>and I have no idea what to change.</p>
  
  <p>if i try <code>$products = $this-&gt;OrderItem-&gt;Product-&gt;find('list');</code>, the error gone. but i need to use find('all') method.</p>
  
  <p>Can anyone help me. thanks in advance.</p>
  
  <p><strong>SET ORIGIN</strong></p>
  
  <ol>
  <li><p>APP\Vendor\dompdf\include\stylesheet.cls.php line 218 → Model->__call(string, array)</p>
  
  <p>'set_origin'
  array(
      (int) 0 => (int) 1
  )</p></li>
  </ol>
  
  <p>2.APP\Vendor\dompdf\include\stylesheet.cls.php line 218 → Style->set_origin(integer)</p>
  
  <pre><code>    else
        $this-&gt;_styles[$key] = clone $style;
  
      $this-&gt;_styles[$key]-&gt;set_origin( $this-&gt;_current_origin );
  
    }
  </code></pre>
  
  <p><strong>pdf/default.ctp</strong></p>
  
  <pre><code>&lt;?php  
  require_once(APP . 'Vendor' . DS . 'dompdf' . DS . 'dompdf_config.inc.php'); 
  spl_autoload_register('DOMPDF_autoload'); 
  $dompdf = new DOMPDF(); 
  $dompdf-&gt;set_paper = 'A4';
  $dompdf-&gt;set_paper("a4", "landscape");
  $dompdf-&gt;load_html(utf8_decode($content_for_layout), Configure::read('App.encoding'));
  $dompdf-&gt;render();
  echo $dompdf-&gt;output();
  </code></pre>
  
  <p><strong>ERROR.LOG</strong></p>
  
  <pre><code>2014-02-03 09:29:17 Error: [PDOException] 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 'set_origin' at line 1
  Request URL: /mall/orderItems/receipt_pdf/201.pdf
  Stack Trace:
  #0 C:\xampp\htdocs\mall\lib\Cake\Model\Datasource\DboSource.php(460): PDOStatement-&gt;execute(Array)
  #1 C:\xampp\htdocs\mall\lib\Cake\Model\Datasource\DboSource.php(426): DboSource-&gt;_execute('set_origin', Array)
  #2 C:\xampp\htdocs\mall\lib\Cake\Model\Datasource\DboSource.php(666): DboSource-&gt;execute('set_origin', Array, Array)
  #3 C:\xampp\htdocs\mall\lib\Cake\Model\Datasource\DboSource.php(611): DboSource-&gt;fetchAll('set_origin', Array, Array)
  #4 C:\xampp\htdocs\mall\lib\Cake\Model\Model.php(799): DboSource-&gt;query('set_origin', Array, Object(Style))
  #5 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\stylesheet.cls.php(218): Model-&gt;__call('set_origin', Array)
  #6 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\stylesheet.cls.php(218): Style-&gt;set_origin(1)
  #7 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\stylesheet.cls.php(1340): Stylesheet-&gt;add_style('html', Object(Style))
  #8 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\stylesheet.cls.php(1077): Stylesheet-&gt;_parse_sections('html { ?  displ...')
  #9 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\stylesheet.cls.php(307): Stylesheet-&gt;_parse_css('/**? * dompdf d...')
  #10 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\dompdf.cls.php(535): Stylesheet-&gt;load_css_file('C:/xampp/htdocs...', 1)
  #11 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\dompdf.cls.php(696): DOMPDF-&gt;_process_html()
  #12 C:\xampp\htdocs\mall\app\View\Layouts\pdf\default.ctp(8): DOMPDF-&gt;render()
  #13 C:\xampp\htdocs\mall\lib\Cake\View\View.php(945): include('C:\xampp\htdocs...')
  #14 C:\xampp\htdocs\mall\lib\Cake\View\View.php(907): View-&gt;_evaluate('C:\xampp\htdocs...', Array)
  #15 C:\xampp\htdocs\mall\lib\Cake\View\View.php(535): View-&gt;_render('C:\xampp\htdocs...')
  #16 C:\xampp\htdocs\mall\lib\Cake\View\View.php(479): View-&gt;renderLayout('', 'default')
  #17 C:\xampp\htdocs\mall\lib\Cake\Controller\Controller.php(952): View-&gt;render(NULL, NULL)
  #18 C:\xampp\htdocs\mall\lib\Cake\Routing\Dispatcher.php(194): Controller-&gt;render()
  #19 C:\xampp\htdocs\mall\lib\Cake\Routing\Dispatcher.php(162): Dispatcher-&gt;_invoke(Object(OrderItemsController), Object(CakeRequest), Object(CakeResponse))
  #20 C:\xampp\htdocs\mall\app\webroot\index.php(110): Dispatcher-&gt;dispatch(Object(CakeRequest), Object(CakeResponse))
  #21 {main}
  </code></pre>
  
  <p>OrderItem model look like this:</p>
  
  <pre><code>    &lt;?php
  App::uses('AppModel', 'Model');
  /**
   * OrderItem Model
   *
   * @property Order $Order
   * @property Product $Product
   */
  class OrderItem extends AppModel {
  
  /**
   * Display field
   *
   * @var string
   */
      public $displayField = 'id';
  
  
      //The Associations below have been created with all possible keys, those that are not needed can be removed
  
  /**
   * belongsTo associations
   *
   * @var array
   */
      public $belongsTo = array(
          'Order' =&gt; array(
              'className' =&gt; 'Order',
              'foreignKey' =&gt; 'order_id',
              'conditions' =&gt; '',
              'fields' =&gt; '',
              'order' =&gt; ''
          ),
          'Product' =&gt; array(
              'className' =&gt; 'Product',
              'foreignKey' =&gt; 'product_id',
              'conditions' =&gt; '',
              'fields' =&gt; '',
              'order' =&gt; ''
          )
      );
  }
  </code></pre>