2013-04-12 73 views
0

我正在使用CakePHP-Photo-Behavior發現在https://github.com/dilab/CakePHP-Photo-Behavior並收到以下錯誤。SQL錯誤:1054:未知列'Array'cakephp 1.3

SQL錯誤:1054:在 '字段列表'[CORE \蛋糕\庫\模型\數據源\ dbo_source.php,線684]未知列 '陣列'

查詢:INSERT INTO photostitledescriptionphoto_dirphotoschool_iduser_idis_slidermodifiedcreated)VALUES( 'skjg', 'lkhg', '',陣列,1,1,1, '2013年4月12日1點14分09秒',「 ')

型號:

var $actsAs = array('Photo'=>array(
        'dir'=>array('upload_directory'), 
        'file_field'=>array('photo'), 
        'file_db_file'=>array('photo'), 
        'thumb'=>array(true), 
        'thumb_size'=>array(array("100x100")) 
)); 

視圖:

<?php echo $this->Form->create('Photo', array('type' => 'file')); ?> 
<?php echo $this->Form->input('Photo.title'); ?> 
<?php echo $this->Form->input('Photo.description', array('type' => 'textarea', 'rows' => 3)); ?> 
<?php echo $this->Form->input('Photo.photo', array('type' => 'file')); ?> 
<?php echo $this->Form->input('Photo.photo_dir', array('type' => 'hidden')); ?> 
<?php echo $this->Form->end(__('Upload', true));?> 

控制器:

function admin_add_slider() { 
    debug($this->params); 

    if (!empty($this->data)) { 

     //set the school id 
     $session_school_id = $this->Session->read('Userinfo.currentSchoolid'); 
     $session_user_id = $this->Session->read('Userinfo.id'); 
     $this->data['Photo']['school_id'] = $session_school_id; 
     $this->data['Photo']['user_id'] = $session_user_id; 
     $this->data['Photo']['is_slider'] = 1; 
     $this->Photo->create(); 
     if ($this->Photo->save($this->data)) { 
      $this->Session->setFlash(__('The Photo has been saved', true)); 
      $this->redirect(array('action' => 'view_slider')); 
     } else { 
      $this->Session->setFlash(__('The Photo could not be saved. Please, try again.', true)); 
     } 
    } 

} 

調試:

data] => Array 
    (
     [Photo] => Array 
      (
       [title] => skjg 
       [description] => lkhg 
       [photo_dir] => 
       [photo] => Array 
        (
         [name] => PLDMonth6Student_img_2.jpg 
         [type] => image/jpeg 
         [tmp_name] => C:\xampp\tmp\phpBA8C.tmp 
         [error] => 0 
         [size] => 42085 
        ) 

      ) 

    ) 

表: idtitledescriptionsmalllargeis_slidercreatedmodifiedschool_iduser_idphotophoto_dir

謝謝 羅伯特

+0

任何幫助嗎?請 – user2272700

回答

0

我沒有使用過這種行爲,但你肯定你成立時間不應該是:

var $actsAs = array('Photo'=>array(
    'dir'=>'upload_directory', 
    'file_field'=>'photo', 
    'file_db_file'=>'photo', 
    'thumb'=>true, 
    'thumb_size'=>array("100x100") 
)); 
+0

這個變化仍然是一樣的錯誤。 – user2272700

0

在配置數組中添加「dbColumn」字段。它只會工作,如果「allowEmpty」。該字段應與您的數據庫列名稱相同。在我的情況下,它的「形象」

public $actsAs = array( 
'Uploader.Attachment' => array(
    'image' => array(
      'baseDir'  => '', 
      'uploadDir'  => 'files/uploads/', 
      'overwrite'  => true, 
      'stopSave'  => true, 
      'allowEmpty' => true, 
      'dbColumn' => 'image'       
    ) 
) 
); 
相關問題