2013-04-12 3 views
0

https://github.com/dilab/CakePHP-Photo-Behavior에있는 CakePHP- 사진 - 동작을 사용 중이고 다음 오류가 발생합니다. photos (title, description INTO INSERT :SQL 오류 : 1054 : 알 수없는 열 '배열'cakephp 1.3

SQL 오류 : 1054 : 684 CORE \ 케이크 \ libs와 \ 모델 \ 데이터 소스 \ dbo_source.php, 라인]

쿼리 '필드 목록'에서 알 수없는 열 '배열' , photo_dir, photo, school_id, user_id, is_slider, modified, created) VALUES ('skjg', 'lkhg', '배열, 1, 1, 1'2013년 4월 12일 1시 14분 9초 ',' 2013-04-12 01:14:09 ')

모델 :

,363,210
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 
        ) 

      ) 

    ) 

테이블 : id, title, description, small, large, 012,319 358,, created, modified, school_id, user_id, photo,

photo_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'       
    ) 
) 
); 
관련 문제