<?php

if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class JobLink_m extends CI_Model

{
    public function all_job_link()

    {

        $query = $this->db->query("SELECT * FROM `jobs`");

        return $query->result();

    }

    public function save_link($link)
    {
        $query = $this->db->query("INSERT INTO `jobs`(`link`) VALUES ('$link')");
    }

    public function delete_link($id)
    {
        $this->db->trans_start();
        $this->db->query("DELETE FROM `jobs` WHERE id = '$id'");
        $this->db->query("SET @num := 0"); 
        $this->db->query("UPDATE jobs SET id = @num := (@num+1)");
        $this->db->query("ALTER TABLE jobs AUTO_INCREMENT = 1");
        $this->db->trans_complete(); 

    }

}