PHP code example of robotusers / cakephp-table-inheritance
1. Go to this page and download the library: Download robotusers/cakephp-table-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/ */
robotusers / cakephp-table-inheritance example snippets
//in ClientsTable:
public function initialize(array $config)
{
$this->addBehavior('Robotusers/TableInheritance.Sti', [
'table' => 'users',
'discriminator' => 'client'
]);
}
//alternative config in AdministratorsTable:
public function initialize(array $config)
{
$this->table('users');
$this->addBehavior('Robotusers/TableInheritance.Sti');
$this->setDiscriminator('admin');
}
//in ImagesTable:
public function initialize(array $config)
{
$this->addBehavior('Robotusers/TableInheritance.Sti', [
'table' => 'files',
'discriminatorField' => 'mime',
'acceptedDiscriminators' => [
'image/jpeg',
'image/gif',
'image/png',
'image/tiff'
]
]);
}
//or using wildcards:
public function initialize(array $config)
{
$this->addBehavior('Robotusers/TableInheritance.Sti', [
'table' => 'files',
'discriminatorField' => 'mime',
'acceptedDiscriminators' => [
'image/*'
]
]);
}