I am using CakePHP-Photo-Behavior found at https://github.com/dilab/CakePHP-Photo-Behavior and receiving the following error.
SQL Error: 1054: Unknown column 'Array' in 'field list' [CORE\\cake\\libs\\model\\datasources\\dbo_source.php, line 684]
Query: INSERT INTO photos
( title
, description
, photo_dir
, photo
, school_id
, user_id
, is_slider
, modified
, created
) VALUES ('skjg', 'lkhg', '', Array, 1, 1, 1, '2013-04-12 01:14:09', '2013-04-12 01:14:09')
model:
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"))
));
view:
<?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));?>
controller:
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));
}
}
}
debug:
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
)
)
)
Table: id
, title
, description
, small
, large
, is_slider
, created
, modified
, school_id
, user_id
, photo
, photo_dir
Thank you Robert
I haven't used that Behaviour, but are you sure your set up shouldn't be:
var $actsAs = array('Photo'=>array(
'dir'=>'upload_directory',
'file_field'=>'photo',
'file_db_file'=>'photo',
'thumb'=>true,
'thumb_size'=>array("100x100")
));
Add "dbColumn" field in configuration array. It will only work if "allowEmpty" is TRUE . This field should be same as your database column name. In my case it's "image"
public $actsAs = array(
'Uploader.Attachment' => array(
'image' => array(
'baseDir' => '',
'uploadDir' => 'files/uploads/',
'overwrite' => true,
'stopSave' => true,
'allowEmpty' => true,
'dbColumn' => 'image'
)
)
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.