Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Tabel extends CI_Model {
- function __construct(){
- parent::__construct();
- $this->load->dbforge();
- }
- function drop_table($table){
- $this->dbforge->drop_table($table);
- }
- function add()
- {
- echo form_open('user');
- $email = array (
- 'name' => 'email',
- 'id' => 'email'
- );
- $username = array(
- 'name' => 'username',
- 'id' => 'username'
- );
- $password = array(
- 'name' => 'password',
- 'id' => 'password'
- );
- echo "email : ". form_input($email). br();
- echo "Username : ". form_input($username). br();
- echo "Password : ". form_password($password). br();
- echo form_submit('submit', 'Login');
- echo form_close();
- echo $msg;
- $format = 'DATE_W3C';
- $time = time();
- $date = standard_date($format, $time);
- $data = array
- (
- 'id' => '' ,
- 'imail' => $email ,
- 'username' => $username,
- 'password' => $password,
- 'is_active' => 1,
- 'last_login' => $date,
- );
- $this->db->insert('users', $data);
- }
- function edit()
- {
- }
- function delete($id)
- {
- $this->db->delete('users', array('id' => $id));
- }
- function create_table($table){
- $this->load->model('tabel');
- function create_table($table){
- $fields = array
- (
- 'id' => array(
- 'type' => 'BIGINT',
- 'constraint' => 20,
- 'null' => FALSE,
- 'auto_increment' => TRUE
- ),
- 'email' => array(
- 'type' => 'VARCHAR',
- 'constraint' => '100',
- 'null' => FALSE
- ),
- 'username' => array(
- 'type' =>'VARCHAR',
- 'constraint' => '50',
- 'null' => FALSE
- ),
- 'password' => array(
- 'type' => 'VARCHAR',
- 'constraint' => '100',
- 'null' => FALSE,
- ),
- 'is_active' => array(
- 'type' => 'TINYINT',
- 'constraint' => '1',
- 'null' => FALSE,
- ),
- 'last_login' => array(
- 'type' => 'DATETIME',
- 'null' => FALSE,
- ),
- );
- $this->dbforge->add_field($fields);
- $this->dbforge->add_key('id', TRUE);
- $this->dbforge->create_table($table, TRUE);
- }
- function first_insert(){
- $format = 'DATE_W3C';
- $time = time();
- $date = standard_date($format, $time);
- $email = "admin@admin.com";
- $username = "admin";
- $password = "admin";
- $data = array
- (
- 'id' => '' ,
- 'imail' => $email ,
- 'username' => $username,
- 'password' => $password,
- 'is_active' => 1,
- 'last_login' => $date,
- );
- $this->db->insert('users', $data);
- }
- function checklogin(){
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $table = 'users';
- $where = array('username' => $username, 'password' => $password);
- $this->db->select()->from($table)->where($where);
- $query = $this->db->get();
- return $query->num_rows();
- }
- function update_date(){
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $format = 'DATE_W3C';
- $time = time();
- $date = standard_date($format, $time);
- $data = array(
- 'last_login' => $date
- );
- $where = array('username' => $username, 'password' => $password);
- $this->db->where($where);
- $this->db->update('users', $data);
- }
- function get_last_ten_entries(){
- $query = $this->db->get('users', 10);
- return $query->result_array();
- }
- }
- }
- /* End of file tabel.php */
- /* Location: ./application/models/tabel.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement