@@ -1351,10 +1351,10 @@ private function _set_relationships()
1351
1351
$ foreign_model = $ relation ;
1352
1352
$ model = $ this ->_parse_model_dir ($ foreign_model );
1353
1353
$ foreign_model = $ model ['foreign_model ' ];
1354
- $ model_dir = $ model ['model_dir ' ];
1354
+ // $model_dir = $model['model_dir'];
1355
1355
$ foreign_model_name = $ model ['foreign_model_name ' ];
1356
1356
1357
- $ this ->load ->model ($ model_dir . $ foreign_model_name );
1357
+ $ this ->load ->model ($ foreign_model , $ foreign_model_name );
1358
1358
$ foreign_table = $ this ->{$ foreign_model_name }->table ;
1359
1359
$ foreign_key = $ this ->{$ foreign_model_name }->primary_key ;
1360
1360
$ local_key = $ this ->primary_key ;
@@ -1368,20 +1368,20 @@ private function _set_relationships()
1368
1368
if ($ this ->is_assoc ($ relation ))
1369
1369
{
1370
1370
$ foreign_model = $ relation ['foreign_model ' ];
1371
+ $ model = $ this ->_parse_model_dir ($ foreign_model );
1372
+ $ foreign_model = $ model ['foreign_model ' ];
1373
+ $ model_dir = $ model ['model_dir ' ];
1374
+ $ foreign_model_name = $ model ['foreign_model_name ' ];
1375
+ $ this ->load ->model ($ model_dir . $ foreign_model , $ foreign_model_name );
1371
1376
if (array_key_exists ('foreign_table ' ,$ relation ))
1372
1377
{
1373
1378
$ foreign_table = $ relation ['foreign_table ' ];
1374
1379
}
1375
1380
else
1376
1381
{
1377
- $ model = $ this ->_parse_model_dir ($ foreign_model );
1378
- $ foreign_model = $ model ['foreign_model ' ];
1379
- $ model_dir = $ model ['model_dir ' ];
1380
- $ foreign_model_name = $ model ['foreign_model_name ' ];
1381
-
1382
- $ this ->load ->model ($ model_dir . $ foreign_model_name );
1383
1382
$ foreign_table = $ this ->{$ foreign_model_name }->table ;
1384
1383
}
1384
+
1385
1385
$ foreign_key = $ relation ['foreign_key ' ];
1386
1386
$ local_key = $ relation ['local_key ' ];
1387
1387
if ($ option =='has_many_pivot ' )
@@ -1421,7 +1421,7 @@ private function _set_relationships()
1421
1421
$ pivot_table = $ tables [0 ].'_ ' .$ tables [1 ];
1422
1422
}
1423
1423
1424
- $ this ->_relationships [$ key ] = array ('relation ' => $ option , 'relation_key ' => $ key , 'foreign_model ' => strtolower ($ foreign_model ), 'foreign_table ' => $ foreign_table , 'foreign_key ' => $ foreign_key , 'local_key ' => $ local_key );
1424
+ $ this ->_relationships [$ key ] = array ('relation ' => $ option , 'relation_key ' => $ key , 'foreign_model ' => strtolower ($ foreign_model ), 'foreign_model_name ' => strtolower ( $ foreign_model_name ), ' foreign_table ' => $ foreign_table , 'foreign_key ' => $ foreign_key , 'local_key ' => $ local_key );
1425
1425
if ($ option == 'has_many_pivot ' )
1426
1426
{
1427
1427
$ this ->_relationships [$ key ]['pivot_table ' ] = $ pivot_table ;
@@ -1966,7 +1966,7 @@ protected function is_assoc(array $array) {
1966
1966
private function _parse_model_dir ($ foreign_model )
1967
1967
{
1968
1968
$ data ['foreign_model ' ] = $ foreign_model ;
1969
- $ data ['model_dir ' ] = NULL ;
1969
+ $ data ['model_dir ' ] = '' ;
1970
1970
1971
1971
$ full_model = explode ('/ ' , $ data ['foreign_model ' ]);
1972
1972
if ($ full_model ) {
@@ -1975,7 +1975,9 @@ private function _parse_model_dir($foreign_model)
1975
1975
$ data ['model_dir ' ] = str_replace ($ data ['foreign_model ' ], null , implode ('/ ' , $ full_model ));
1976
1976
}
1977
1977
1978
- $ data ['foreign_model_name ' ] = strtolower ($ data ['foreign_model ' ]);
1978
+ $ foreign_model_name = str_replace ('/ ' ,'_ ' ,$ data ['model_dir ' ].$ data ['foreign_model ' ]);
1979
+
1980
+ $ data ['foreign_model_name ' ] = strtolower ($ foreign_model_name );
1979
1981
1980
1982
return $ data ;
1981
1983
}
0 commit comments