Merge pull request #1187 from AndreasK79/notes_assign_to_user

Notes assign to user
pull/1188/head^2
Andreas Kristiansen 2021-09-20 19:32:59 +02:00 zatwierdzone przez GitHub
commit ad045a1a8d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 30 dodań i 7 usunięć

Wyświetl plik

@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
*/
$config['migration_version'] = 75;
$config['migration_version'] = 76;
/*
|--------------------------------------------------------------------------

Wyświetl plik

@ -0,0 +1,19 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Migration_add_userid_to_notes extends CI_Migration
{
public function up()
{
$fields = array(
'user_id BIGINT(20) DEFAULT NULL',
);
$this->dbforge->add_column('notes', $fields);
}
public function down()
{
$this->dbforge->drop_column('notes', 'user_id');
}
}

Wyświetl plik

@ -9,6 +9,7 @@ class Note extends CI_Model {
}
function list_all() {
$this->db->where('user_id', $this->session->userdata('user_id'));
return $this->db->get('notes');
}
@ -16,10 +17,11 @@ class Note extends CI_Model {
$data = array(
'cat' => xss_clean($this->input->post('category')),
'title' => xss_clean($this->input->post('title')),
'note' => xss_clean($this->input->post('content'))
'note' => xss_clean($this->input->post('content')),
'user_id' => $this->session->userdata('user_id')
);
$this->db->insert('notes', $data);
$this->db->insert('notes', $data);
}
function edit() {
@ -30,19 +32,21 @@ class Note extends CI_Model {
);
$this->db->where('id', xss_clean($this->input->post('id')));
$this->db->update('notes', $data);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->update('notes', $data);
}
function delete($id) {
$this->db->delete('notes', array('id' => xss_clean($id)));
$this->db->delete('notes', array('id' => xss_clean($id), 'user_id' =>$this->session->userdata('user_id')));
}
function view($id) {
// Get Note
$this->db->where('id', xss_clean($id));
$this->db->where('id', xss_clean($id));
$this->db->where('user_id', $this->session->userdata('user_id'));
return $this->db->get('notes');
}
}
?>
?>