当我试图在cakedc插件中使用cvdimport行为时,我得到了这个错误。
语法错误或访问冲突: 1064在SQL语法中有错误;检查与MySQL服务器版本对应的手册,以获得在第1行“getImportErrors”附近使用的正确语法。
这里是导入函数
function import() {
$modelClass = $this->modelClass;
if( $this->request->is('POST')) {
$records_count = $this->$modelClass->find('count');
try {
$this->$modelClass->importCSV($this->request->data[$modelClass]['CsvFile']['tmp_name']);
}
catch (Exception $e) {
$import_errors = $this->$modelClass->getImportErrors();
$this->set('import_errors', $import_errors);
$this->Session->setFlash(__('Error Importing')." ".$this->request->data[$modelClass]['CsvFile']['name'] ." ," . __('column name mismatch.'));
$this->redirect(array('action' => 'import'));
}
$new_records_count = $this->$modelClass->find('count') - $records_count;
$this->Session->setFlash(__('Successfully Imported') . " " . $new_records_count . 'records from' . $this->request->data[$modelClass]['CvsFile']['name']);
$this->redirect(array('action' => 'index'));
}
$this->set('modelClass',$modelClass);
$this->render('../Common/import');
}//end import和位于公共目录中的视图文件
<h3>Import <?php echo Inflector::pluralize($modelClass); ?> from CSV data file</h3>
<?php
echo $this->Form->create($modelClass, array('action' => 'import', 'type' => 'file'));
echo $this->Form->input('CsvFile', array('label' => '', 'type' => 'file'));
echo $this->Form->end('Submit');?>
错误的行是: $import_errors =$this->$modelClass->getImportError();
有人能告诉我是什么导致了这个错误吗。我不知道该怎么做才能使它发挥作用。
发布于 2014-12-21 21:15:50
当在模型上获得方法调用的SQL错误时,这通常意味着行为没有加载。找出原因。
https://stackoverflow.com/questions/27592552
复制相似问题