Laoder make is to load any model name in unix * Unix like OS are CAmelCase so lest permit to load models from CI3 or CI2 no matter if first is uppercase
| ... | ... | @@ -226,14 +226,18 @@ class CI_Loader { |
| 226 | 226 | *
|
| 227 | 227 | * This function lets users load and instantiate models.
|
| 228 | 228 | *
|
| 229 | - * @param string the name of the class
|
|
| 230 | - * @param string name for the model
|
|
| 231 | - * @param bool database connection
|
|
| 232 | - * @return void
|
|
| 229 | + * @param mixed $model Model name
|
|
| 230 | + * @param string $name An optional object name to assign to
|
|
| 231 | + * @param bool $db_conn An optional database connection configuration to initialize
|
|
| 232 | + * @return object
|
|
| 233 | 233 | */
|
| 234 | 234 | public function model($model, $name = '', $db_conn = FALSE)
|
| 235 | 235 | {
|
| 236 | - if (is_array($model))
|
|
| 236 | + if (empty($model))
|
|
| 237 | + {
|
|
| 238 | + return;
|
|
| 239 | + }
|
|
| 240 | + elseif (is_array($model))
|
|
| 237 | 241 | {
|
| 238 | 242 | foreach ($model as $babe)
|
| 239 | 243 | {
|
| ... | ... | @@ -242,11 +246,6 @@ class CI_Loader { |
| 242 | 246 | return;
|
| 243 | 247 | }
|
| 244 | 248 | |
| 245 | - if ($model == '')
|
|
| 246 | - {
|
|
| 247 | - return;
|
|
| 248 | - }
|
|
| 249 | - |
|
| 250 | 249 | $path = '';
|
| 251 | 250 | |
| 252 | 251 | // Is the model in a sub-folder? If so, parse out the filename and path.
|
| ... | ... | @@ -259,9 +258,9 @@ class CI_Loader { |
| 259 | 258 | $model = substr($model, $last_slash + 1);
|
| 260 | 259 | }
|
| 261 | 260 | |
| 262 | - if (empty($name))
|
|
| 261 | + if (empty(trim($name)))
|
|
| 263 | 262 | {
|
| 264 | - $name = $model;
|
|
| 263 | + $name = strtolower($model);
|
|
| 265 | 264 | }
|
| 266 | 265 | |
| 267 | 266 | if (in_array($name, $this->_ci_models, TRUE))
|
| ... | ... | @@ -275,14 +274,22 @@ class CI_Loader { |
| 275 | 274 | show_error('The model name you are loading is the name of a resource that is already being used: '.$name);
|
| 276 | 275 | }
|
| 277 | 276 | |
| 278 | - $model = strtolower($model);
|
|
| 279 | - |
|
| 280 | 277 | foreach ($this->_ci_model_paths as $mod_path)
|
| 281 | 278 | {
|
| 282 | 279 | if ( ! file_exists($mod_path.'models/'.$path.$model.'.php'))
|
| 283 | 280 | {
|
| 284 | 281 | continue;
|
| 285 | 282 | }
|
| 283 | + if ( ! file_exists($mod_path.'models/'.$path.strtolower($model).'.php'))
|
|
| 284 | + {
|
|
| 285 | + $model = strtolower($model);
|
|
| 286 | + continue;
|
|
| 287 | + }
|
|
| 288 | + elseif ( ! file_exists($mod_path.'models/'.$path.ucfirst($model).'.php'))
|
|
| 289 | + {
|
|
| 290 | + $model = ucfirst($model);
|
|
| 291 | + continue;
|
|
| 292 | + }
|
|
| 286 | 293 | |
| 287 | 294 | if ($db_conn !== FALSE AND ! class_exists('CI_DB'))
|
| 288 | 295 | {
|
—
View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help