Welcome Guest, Not a member yet? Register   Sign In
extend DB table with edit by field
#1

hello,

we have same backend make by a freelancer and he end the job.
now we try to understand codeigniter and this doing.  Confused

we want to extend our database model with a hidden fielt edit_by with value from the editing user logined right now in the backend.
DB Field names "edit_by"

any help for us???

CONTROLLER
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Bars extends CI_Controller {

 public function 
__construct()
 {
 
parent::__construct();

 
$this->load->database();
 
$this->load->helper('url');

 
$this->load->library('grocery_CRUD');
 }

 public function 
data_output($output null)
 {
 
$data['page'] = 'barsview';
 
$data['output']=$output;
 
     $this->load->view('template'$data);
 }
 function 
modified_callback($post_array$primary_key) {
 
$post_array['modified']=time();
 return 
$post_array;
 }
 function 
inserted_callback($post_array$primary_key) {
 
$post_array['modified']=time();
 return 
$post_array;
 }
 public function 
index()
 {
 try{
 
$crud = new grocery_CRUD();

 
//$crud->set_theme('datatables');
 
$crud->set_table('bars');
 
$crud->set_subject('Bar');
 
$crud->change_field_type('show_contact_details','true_false');
 
$crud->change_field_type('modified','invisible');
 
$crud->callback_before_update(array($this,'modified_callback'));
 
$crud->callback_before_insert(array($this,'inserted_callback'));
 
$crud->set_rules('popularity','Popularity','integer');
 
$crud->set_rules('popularity''Popularity''required|xss_clean|max_length[5]');
 
$crud->required_fields('name''description''image''address''zipcode''city''latitude''longitude''availability''price''priority''reviews');
 
$crud->unset_texteditor('reviewlink','full_text');
 
$crud->unset_texteditor('moreinfo','full_text');
 
$crud->unset_texteditor('overview','full_text');
 
$crud->unset_texteditor('address','full_text');
 
$crud->set_field_upload('image','assets/restaurantsUploads/');
 
     $crud->callback_column('image',array($this,'_callback_fun'));
 
$crud->columns('name''description''image''address''zipcode''city' 'popularity''edit_by');
 
 
$output $crud->render();

 
$this->data_output($output);

 }catch(
Exception $e){
 
show_error($e->getMessage().' --- '.$e->getTraceAsString());
 }
 }

 


VIEW
PHP Code:
<?php 
foreach($css_files as $file): ?>
 <link type="text/css" rel="stylesheet" href="<?php echo $file?>" />
<?php endforeach; ?>
<?php 
foreach($js_files as $file): ?>
 <script src="<?php echo $file?>"></script>
<?php endforeach; ?>

    <div>
 <?php echo $output?>
    </div> 
Reply


Messages In This Thread
extend DB table with edit by field - by Lordi - 11-30-2014, 08:24 AM
RE: extend DB table with edit by field - by Lordi - 12-06-2014, 08:14 AM
RE: extend DB table with edit by field - by Lordi - 12-24-2014, 03:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB