【发布时间】:2014-02-03 07:51:46
【问题描述】:
我收到了这个错误:
SQLSTATE[42000]:语法错误或访问冲突:1064 你有一个 SQL 语法错误;检查与您对应的手册 MySQL 服务器版本,在 'set_origin' 附近使用正确的语法 第 1 行
当我在我的 OrderItems 控制器中添加此行时会发生此错误。
$products = $this->OrderItem->Product->find('all');
我不知道要改变什么。
如果我尝试$products = $this->OrderItem->Product->find('list');,错误就消失了。但我需要使用 find('all') 方法。
谁能帮帮我。提前致谢。
设置原点
-
APP\Vendor\dompdf\include\stylesheet.cls.php 第 218 行 → 模型->__call(string, array)
'set_origin' 大批( (int) 0 => (int) 1 )
2.APP\Vendor\dompdf\include\stylesheet.cls.php 第 218 行 → 样式->set_origin(integer)
else
$this->_styles[$key] = clone $style;
$this->_styles[$key]->set_origin( $this->_current_origin );
}
pdf/default.ctp
<?php
require_once(APP . 'Vendor' . DS . 'dompdf' . DS . 'dompdf_config.inc.php');
spl_autoload_register('DOMPDF_autoload');
$dompdf = new DOMPDF();
$dompdf->set_paper = 'A4';
$dompdf->set_paper("a4", "landscape");
$dompdf->load_html(utf8_decode($content_for_layout), Configure::read('App.encoding'));
$dompdf->render();
echo $dompdf->output();
ERROR.LOG
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->execute(Array)
#1 C:\xampp\htdocs\mall\lib\Cake\Model\Datasource\DboSource.php(426): DboSource->_execute('set_origin', Array)
#2 C:\xampp\htdocs\mall\lib\Cake\Model\Datasource\DboSource.php(666): DboSource->execute('set_origin', Array, Array)
#3 C:\xampp\htdocs\mall\lib\Cake\Model\Datasource\DboSource.php(611): DboSource->fetchAll('set_origin', Array, Array)
#4 C:\xampp\htdocs\mall\lib\Cake\Model\Model.php(799): DboSource->query('set_origin', Array, Object(Style))
#5 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\stylesheet.cls.php(218): Model->__call('set_origin', Array)
#6 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\stylesheet.cls.php(218): Style->set_origin(1)
#7 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\stylesheet.cls.php(1340): Stylesheet->add_style('html', Object(Style))
#8 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\stylesheet.cls.php(1077): Stylesheet->_parse_sections('html { ? displ...')
#9 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\stylesheet.cls.php(307): Stylesheet->_parse_css('/**? * dompdf d...')
#10 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\dompdf.cls.php(535): Stylesheet->load_css_file('C:/xampp/htdocs...', 1)
#11 C:\xampp\htdocs\mall\app\Vendor\dompdf\include\dompdf.cls.php(696): DOMPDF->_process_html()
#12 C:\xampp\htdocs\mall\app\View\Layouts\pdf\default.ctp(8): DOMPDF->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->_evaluate('C:\xampp\htdocs...', Array)
#15 C:\xampp\htdocs\mall\lib\Cake\View\View.php(535): View->_render('C:\xampp\htdocs...')
#16 C:\xampp\htdocs\mall\lib\Cake\View\View.php(479): View->renderLayout('', 'default')
#17 C:\xampp\htdocs\mall\lib\Cake\Controller\Controller.php(952): View->render(NULL, NULL)
#18 C:\xampp\htdocs\mall\lib\Cake\Routing\Dispatcher.php(194): Controller->render()
#19 C:\xampp\htdocs\mall\lib\Cake\Routing\Dispatcher.php(162): Dispatcher->_invoke(Object(OrderItemsController), Object(CakeRequest), Object(CakeResponse))
#20 C:\xampp\htdocs\mall\app\webroot\index.php(110): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#21 {main}
OrderItem 模型如下所示:
<?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' => array(
'className' => 'Order',
'foreignKey' => 'order_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Product' => array(
'className' => 'Product',
'foreignKey' => 'product_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
【问题讨论】:
-
你能粘贴(部分)
OrderItem模型的内容吗? -
您可能错过了右括号或其他内容。只需打印查询。
-
@cornelb 我已经更新了我的问题。我把 OrderItem 模型的内容。
-
@JensonMJohn 嗨,对不起,我还是 cakephp 新手。打印查询是什么意思?
-
@user3073725 blog.tersmitten.nl/…