[ERROR#1] Connection — Documentation — DIAFAN.CMS

Connection

In use the module to other modules in the file modules/module_name/module_name.inc.php described Module_name_inc.

Appeal to the module connection is through variable $this->diafan->_module_name. The first time the variable is instantiated class Module_name_inc.

Connection class inherits class Model described in the file includes/model.php. His description, refer to "Model".

The module model can appeal to a public function module is connected via a variable $this->inc.

For example, let's sell the news by its ID from anywhere in DIAFAN.CMS.

To do this, create in the folder modules/news/ file news.inc.php.

Example:

<?php
class News_inc extends Model
{
    
/**
    * Get news
    * @param int $id ID news
    * @return array or null in news not found
    */
    
public function get($id)
    {
        
$row = DB::query_fetch_array("SELECT [name], [anons] FROM {news} WHERE id=%d AND [act]='1' AND trash='0'", $id);

        return
$row;
    }
}

We verify our method in the file modules/shop/shop.model.php in the function get_result(), which returns the results generated in the shop model. Fill in:

Example:

$this->result["news"] = $this->diafan->_news->get(1);
print_r($this->result["news"]);
exit;

Turning on the catalog page, we should see our news item under the ID 1.

Methods with the same name as their class will not be constructors in a future version of PHP; Markdown_Parser has a deprecated constructor
#1 include_once() called at [/var/www/diafan/data/www/diafancms.com/modules/docs/docs.model.php:499]
#2 Docs_model->prepare_text( In use the module to other modules in the file *modules/module_name/module_name.inc.php* described *Module_name_inc*. Appeal to the module connection is through variable `$this->diafan->_modul...) called at [/var/www/diafan/data/www/diafancms.com/modules/docs/docs.model.php:94]
#3 Docs_model->show() called at [/var/www/diafan/data/www/diafancms.com/modules/docs/docs.php:29]
#4 Docs->init() called at [/var/www/diafan/data/www/diafancms.com/includes/init.php:474]
#5 Init->module() called at [/var/www/diafan/data/www/diafancms.com/includes/init.php:119]
#6 Init->start() called at [/var/www/diafan/data/www/diafancms.com/index.php:62]
/var/www/diafan/data/www/diafancms.com/modules/docs/docs.model.php:499