Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
themeRDark
borderStylesolid
linenumberstrue
collapsetrue
<?php

namespace Apps\TodoList\Installation\Database;

use Core\App\Install\Database\Table;

class TodoTaskTable extends Table
{
    /**
     * Set name of this table, can't missing
     */
    protected function setTableName()
    {
        $this->_table_name = 'todolist_task';
    }

    /**
     * Set all fields of table
     */
    protected function setFieldParams()
    {
        $this->_aFieldParams = [
            'task_id' => [
                'primary_key' => true,
                'auto_increment' => true,
                'type' => 'int',
                'type_value' => 10,
                'other' => 'UNSIGNED NOT NULL'
            ],
            'user_id' => [
                'type' => 'int',
                'type_value' => 10,
                'other' => 'UNSIGNED NOT NULL'
            ],
            'name' => [
                'type' => 'varchar',
                'type_value' => 255,
                'other' => 'NOT NULL DEFAULT \'\''
            ],
            'description' => [
                'type' => 'text',
                'other' => 'NOT NULL DEFAULT \'\''
            ],
            'task_status' => [
                'type' => 'tinyint',
                'type_value' => 3,
                'other' => 'UNSIGNED NOT NULL DEFAULT 0'
            ],
            'is_sponsor' => [
                'type' => 'tinyint',
                'type_value' => 1,
                'other' => 'UNSIGNED NOT NULL DEFAULT 0'
            ],
            'time_stamp' => [
                'type' => 'int',
                'type_value' => 10,
                'other' => 'UNSIGNED NOT NULL'
            ],
            'time_update' => [
                'type' => 'int',
                'type_value' => 10,
                'other' => 'UNSIGNED NOT NULL DEFAULT 0'
            ],
            'privacy' => [
                'type' => 'tinyint',
                'type_value' => 1,
                'other' => 'NOT NULL DEFAULT 0'
            ],
            'total_comment' => [
                'type' => 'int',
                'type_value' => 10,
                'other' => 'UNSIGNED NOT NULL DEFAULT 0'
            ],
            'total_view' => [
                'type' => 'int',
                'type_value' => 10,
                'other' => 'UNSIGNED NOT NULL DEFAULT 0'
            ],
            'total_like' => [
                'type' => 'int',
                'type_value' => 10,
                'other' => 'UNSIGNED NOT NULL DEFAULT 0'
            ],
            'image_path' => [
                'type' => 'varchar',
                'type_value' => '75',
                'other' => 'DEFAULT NULL',
            ],
            'server_id' => [
                'type' => 'tinyint',
                'type_value' => '1',
                'other' => 'NOT NULL DEFAULT \'0\'',
            ],
        ];
    }
    /**
     * Set keys of table
     */
    protected function setKeys()
    {
        $this->_key = [
            'task_id' => ['task_id','task_status'],
            'user_id' => ['user_id']
        ];
    }
}

Final, in file Install.php (configuration file of your app), add the table to your app database configuration:

...