aJ5dY4aD9y
Do³±czy³: 09 Maj 2014 Posty: 99
|
Wys³any: Wto Maj 13, 2014 03:33 Temat postu: guild wars 2 gold Association and model data saving problem |
|
|
public $hasAndBelongsToMany = array('Tag');public function beforeSave($options = array()) { if (isset($this-data[$this-alias]['tags']) !empty($this-data[$this-alias]['tags'])) { $tagIds = $this-Tag-saveDocTags($this-data[$this-alias]['tags']); unset($this-data[$this-alias]['tags']); $this-data[$this-Tag-alias][$this-Tag-alias] = $tagIds; return true; }class Tag extends AppModel public $hasAndBelongsToMany = array ('Document'); public function saveDocTags($commalist = '') { if ($commalist == '') return null; $tags = explode(',',$commalist); if (empty($tags)) return null; $existing = $this-find('all', array( 'conditions' = array('title' = $tags) )); $return = Set::extract($existing,'/Tag/id'); if (sizeof($existing) == sizeof($tags)) { return $return; $existing = Set::extract($existing,'/Tag/title'); foreach ($tags as $tag) if (!in_array($tag, $existing)) { $this-create(array('title' = $tag)); $this-save(); $return[] = $this-id; So, new tags creation works well but document model can't save association data and tells:SQL Error: 1054: Unknown column 'Array' in 'field list'Query: INSERT INTO documents ( title , content , shortnfo , date , status ) VALUES ('Document with tags', '', '', Array, 1) Any ideas how to solve this problem? P. <a href="http://www.goldvk.com/Game.gw2_us.Guild Wars 2.gw2.Gold.Info.aspx">guild wars 2 gold</a> S. Post data from firebug for this form:_method POSTdata[Document][content] test document contentdata[Document][date][year] 2010data[Document][shortnfo] short info about documentdata[Document][status] 1data[Document][tags] test, categories, listdata[Document][title] Test titleNo arrays as we can see. xboter 2014 |
|