Mudanças entre as edições de "CodeIgniter 4"
Ir para navegação
Ir para pesquisar
| Linha 24: | Linha 24: | ||
php spark make:migration __nome_da_classe_(nao repetir)__ | php spark make:migration __nome_da_classe_(nao repetir)__ | ||
Estrutura do arquivo | Estrutura do arquivo | ||
| − | + | public function up() | |
{ | { | ||
// | // | ||
| Linha 39: | Linha 39: | ||
'type' => 'VARCHAR', | 'type' => 'VARCHAR', | ||
'constraint' => '20' | 'constraint' => '20' | ||
| − | + | ], | |
'p_title' => [ | 'p_title' => [ | ||
'type' => 'TEXT' | 'type' => 'TEXT' | ||
Edição das 12h19min de 5 de julho de 2021
Índice
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