db = \Config\Database::connect();
$this->db->initialize();
}
public function index()
{
$query = $this->db->table('my_table')->get();
echo '';
foreach ($query->getResult() as $row) {
echo '- ';
echo $row->title;
echo '
';
}
echo '
';
}
public function insert()
{
echo '쿼리 빌더 Insert
';
$data = [
'title' => date('Y-m-d H:i:s') . ' - title',
'name' => 'test',
'email' => 'test@test.com'
];
$this->db->table('my_table_insert')->insert($data);
echo '';
print_r($this->db->table('my_table_insert')->get()->getResult());
echo '
';
$this->db->table('my_table_insert')->truncate();
}
}