PHP code example of pchec / cakephp-inheritance

1. Go to this page and download the library: Download pchec/cakephp-inheritance library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pchec / cakephp-inheritance example snippets


class YourTable extends Table
{
    public function initialize(array $config)
    {
        parent::initialize($config);

        $this->table('your_table_name');
        $this->addBehavior('Inheritance.SingleTable');

        // Rest of the initialization code...
    }

    // Rest of the code...
}

class YourChildTable extends YourTable
{
    public function initialize(array $config)
    {
        parent::initialize($config);

        $this->table('your_table_name'); // Needs to be the same as in the parent
        $this->addBehavior('Inheritance.SingleTable');

        // Rest of the initialization code...
    }

    // Rest of the code...
}

$this->addBehavior('Inheritance.SingleTable', [
	'hierarchy' => false,
]);

$this->addBehavior('Inheritance.SingleTable', [
	'table' => 'your_table_name',
]);