| 219 | | $join_model_file = AkInflector::toModelFilename($options['join_class_name']); |
|---|
| 220 | | if(file_exists($join_model_file)){ |
|---|
| 221 | | require_once($join_model_file); |
|---|
| 222 | | if(class_exists($options['join_class_name'])){ |
|---|
| 223 | | $this->JoinObject =& new $options['join_class_name'](); |
|---|
| | 219 | if (class_exists($options['join_class_name']) || $this->_loadJoinClass($options['join_class_name']) || $this->_createJoinClass()) { |
|---|
| | 220 | $this->JoinObject =& new $options['join_class_name'](); |
|---|
| | 221 | //if($this->JoinObject->setTableName($options['join_table'], true, true) || $this->_createJoinTable()){ |
|---|
| | 222 | if($this->_tableExists($options['join_table']) || $this->_createJoinTable()){ |
|---|
| 226 | | } |
|---|
| 227 | | } |
|---|
| 228 | | if($this->_createJoinClass()){ |
|---|
| 229 | | $this->JoinObject =& new $options['join_class_name'](); |
|---|
| 230 | | if(!$this->_hasJoinTable()){ |
|---|
| 231 | | $this->_createJoinTable() ? null : trigger_error(Ak::t('Could not find join table %table_name for hasAndBelongsToMany association %id',array('%table_name'=>$options['join_table'],'id'=>$this->association_id)),E_USER_ERROR); |
|---|
| 232 | | } |
|---|
| 233 | | $this->JoinObject->setPrimaryKey($options['foreign_key']); |
|---|
| 234 | | return true; |
|---|
| 235 | | } |
|---|
| | 225 | |
|---|
| | 226 | } else trigger_error(Ak::t('Could not find join table %table_name for hasAndBelongsToMany association %id',array('%table_name'=>$options['join_table'],'id'=>$this->association_id)),E_USER_ERROR); |
|---|
| | 227 | } else trigger_error(Ak::t('Could not find join model %model_name for hasAndBelongsToMany association %id',array('%table_name'=>$options['join_class_name'],'id'=>$this->association_id)),E_USER_ERROR); return false; |
|---|
| 260 | | $class_file_code .= $class_code. "\n\n?>"; |
|---|
| 261 | | $join_file = AkInflector::toModelFilename($options['join_class_name']); |
|---|
| 262 | | if($this->_automatically_create_join_model_files && !file_exists($join_file) && @Ak::file_put_contents($join_file, $class_file_code)){ |
|---|
| 263 | | require_once($join_file); |
|---|
| 264 | | }else{ |
|---|
| 265 | | eval($class_code); |
|---|
| 266 | | } |
|---|
| | 259 | $class_file_code .= $class_code. "\n\n?>"; |
|---|
| | 260 | $join_file = AkInflector::toModelFilename($options['join_class_name']); |
|---|
| | 261 | if($this->_automatically_create_join_model_files && !file_exists($join_file) && @Ak::file_put_contents($join_file, $class_file_code)){ |
|---|
| | 262 | require_once($join_file); |
|---|
| | 263 | }else{ |
|---|
| | 264 | eval($class_code); |
|---|
| 283 | | require_once(AK_LIB_DIR.DS.'AkDbManager.php'); |
|---|
| 284 | | |
|---|
| 285 | | AkDbManager::createTable($options['join_table'], "id I AUTO KEY,{$options['foreign_key']} I, {$options['association_foreign_key']} I",array('mysql' => 'TYPE=InnoDB'),false, |
|---|
| 286 | | "{$options['foreign_key']},{$options['association_foreign_key']}"); |
|---|
| 287 | | return $this->_hasJoinTable(); |
|---|
| 288 | | } |
|---|
| 289 | | |
|---|
| 290 | | |
|---|
| | 277 | require_once(AK_LIB_DIR.DS.'AkInstaller.php'); |
|---|
| | 278 | $Installer =& new AkInstaller(); |
|---|
| | 279 | $Installer->createTable($options['join_table'],"id,{$options['foreign_key']},{$options['association_foreign_key']}"); |
|---|
| | 280 | return $this->JoinObject->setTableName($options['join_table'],false); |
|---|
| | 281 | } |
|---|