Mudanças entre as edições de "CodeIgniter 4"

De BrapciWiki
Ir para navegação Ir para pesquisar
Linha 26: Linha 26:
 
public function up()
 
public function up()
 
{
 
{
//
+
//
 
         $this->forge->addField([
 
         $this->forge->addField([
 
             'id_p' => [
 
             'id_p' => [
Linha 43: Linha 43:
 
                 'type' => 'TEXT'
 
                 'type' => 'TEXT'
 
],
 
],
 
 
'created_at datetime default current_timestamp',
 
'created_at datetime default current_timestamp',
 
             'updated_at datetime default current_timestamp on update current_timestamp'
 
             'updated_at datetime default current_timestamp on update current_timestamp'

Edição das 12h19min de 5 de julho de 2021

Instalação

Configuração Inicial

Alterar o nome do arquivo "env" para ".env" Dentro do arquivo, alterar o tipo:

CI_ENVIRONMENT = production

ou

CI_ENVIRONMENT = developent

Configure a conexão com o banco de dados database.default.hostname = MariaDB database.default.database = cip database.default.username = root database.default.password = root database.default.DBDriver = MySQLi database.default.DBPrefix =

SPARK

php spark migrate

Criar um arquivo de migração de banco de dados

  php spark make:migration __nome_da_classe_(nao repetir)__

Estrutura do arquivo public function up() { //

       $this->forge->addField([
           'id_p' => [
               'type' => 'INT',
               'auto_increment' => true
           ],
           'p_ip' => [
               'type' => 'VARCHAR',
               'constraint' => '20'
           ],
           'p_family' => [
               'type' => 'VARCHAR',
               'constraint' => '20'

],

           'p_title' => [
               'type' => 'TEXT'

], 'created_at datetime default current_timestamp',

           'updated_at datetime default current_timestamp on update current_timestamp'
       ]);
       $this->forge->addKey('id_p', true);
       $this->forge->createTable('patents');	

}

Criar um model

php spark make:model Patents