I am newbie in PHP, I have faced with weird thing for me in opencart PHP engine.
There is file called catalog/controller/module/slideshow.php
.
This class extends Controller
class
class ControllerModuleSlideshow extends Controller {
protected function index($setting) {
static $module = 0;
$this->load->model('design/banner');
$this->load->model('tool/image');
.....
$this->model_design_banner->getBanner($setting['banner_id']);
.....
Hm $this->model_design_banner
there is no such member in this class, oh probably it is in parent class.
Let's check this, cd....
<?php
abstract class Controller {
protected $registry;
protected $id;
protected $layout;
protected $template;
protected $children = array();
protected $data = array();
protected $output;
Hm .... ??!!! WTF (sorry)
There is no such member in this class too.......
I guessed that is shortcut for catalog/controller/module/banner.php
// Here are a lot questions how , where ?
Let's open catalog/model/design/banner.php
<?php
class ModelDesignBanner extends Model {
public function getBanner($banner_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "banner_image bi LEFT JOIN " . DB_PREFIX . "banner_image_description bid ON (bi.banner_image_id = bid.banner_image_id) WHERE bi.banner_id = '" . (int)$banner_id . "' AND bid.language_id = '" . (int)$this->config->get('config_language_id') . "'");
return $query->rows;
}
}
Okey it without previous questions it looks normal... stop !
If we can call method shortcut it should be static ... .
$this->db->query
In this case should point to nothing ....
So a lot of weird things for me
How does this really work. How does shortcut is mapped to function, why function is not static and so on.
Please explain this, I will be grateful for any help.
EDIT
If load object has method that loads model in my class where does load method is declared,there is also this so it should be in same class.