Anda di halaman 1dari 8

1) 2) 3) difference between Class and Helper provided by Codeigniter.

Why did not Codeigniter just introduced everything in form of class, why would they need to separate it as a helper instead. 4) How to access values passed in url---in CI $this->input->get('status'); done 5) Router : $this->controller_name = $this->router->fetch_directory() . $this->router>fetch_class(); 6)

Functions present in MyController load_defaults render add_css alreadyLoggedIn confirmPassword checkEmail checkAccountId checkExpiryMonth checkExpiryYear validPhone array_depth Issues as on sep 17 1)Router Router : $this->controller_name = $this->router->fetch_directory() . $this->router>fetch_class(); 2)Hooks 3)class MY_Controller extends CI_Controller Where is CI_Controller ?? 4)$this->CI =& get_instance(); used for assigning object to a variable -------- System/libraries/session.php Issues as on sep 19 1)error Status: 'error'. Error code: 500 http://dev.loyalty.com//index/loadDataGrid_testSearch

{ "page":1, "total":3, "records":13, "rows":[ {"id":"1","cell":[1,"sandeep","123-456","8800337144"]}, {"id":"2","cell":[2,"abc","123-4568","8800337144"]}, {"id":"3","cell":[3,"sandeep","123-4567","8800337144"]}, {"id":"4","cell":[4,"rajan","123-456","8800337144"]}, {"id":"5","cell":[5,"sandeepdfdf","123-456","8800337144"]}, {"id":"9","cell":[6,"xxx","13123123",""]}, {"id":"10","cell":[7,"sa","123-456",""]}, {"id":"11","cell":[8,"sandeep1","123-456","8800337144"]}, {"id":"12","cell":[9,"maneesh","123-456","8800337144"]}, {"id":"15","cell":[10,"Gaurav","11111",null]}, {"id":"16","cell":[11,"asd","+91(123)-456",""]}, {"id":"17","cell":[12,"prathish","0112535","9999887897"]}, {"id":"18","cell":[13,"roger","0112345","9987564575"]} ] } function loadDataGrid_testSearch() { $this->load->model('mdaily'); $this->load->helper(array('form', 'url')); $urldata=$this->input->post('search_data'); if(isset($urldata) && ($urldata!='') ){ $urldata_arr=explode('!^',$urldata); $fname=explode('=',$urldata_arr['0']); $phonenum=explode('=',$urldata_arr['1']); } if(isset($fname[1])) $name = $fname[1]; else $name = ""; if(isset($phonenum[1])) $phone = $phonenum[1]; else $phone = ""; $page = isset($_POST['page']) ? $_POST['page'] : 1; // get the requested page $limit = isset($_POST['rows']) ? $_POST['rows'] : 5; // get how many rows we want to have into the grid // $page = $this->input->post('page'); // $limit = $this->input->post('rows'); $sidx = isset($_POST['sidx']) ? $_POST['sidx'] : 'id'; // get index row - i.e. user click to sort $sord = isset($_POST['sord']) ? $_POST['sord'] : ''; // get the direction

if (!$sidx) $sidx = 1; $start=0; $query1 = $this->mdaily->getAllSearch($name,$phone,$limit, $sidx, $sord,$start); $count = count($query1); if ($count > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } if ($page > $total_pages) $page = $total_pages; $start = $limit * $page - $limit; // do not put $limit*($page - 1) $start = ($start < 0) ? 0 : $start; // make sure that $start is not a negative value $query = $this->mdaily->getAllSearchU($name,$phone,$limit, $sidx, $sord,$start); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i = 0; foreach ($query as $row) { $responce->rows[$i]['id'] = $row->id; $responce->rows[$i]['cell'] = array($i + 1, $row->first_name, $row->phone_number, $row->mobile); $i++; } echo json_encode($responce); } Mdaily.php function getAllSearch($name,$phone,$limit,$sidx,$sord,$start){ // custom query select * from user where first_name like '% $name %' and phone_number like '% $phone %' //$where = "first_name like '% $name %' and phone_number like '% $phone %'"; $this->db->select('id,first_name,phone_number,mobile'); $this->db->from('user'); //$this->db->where('first_name',$name); //$this->db->or_where('phone_number',$phone); //$array = array('first_name' => $name, 'phone_number' => $phone); // $this->db->where($array); $this->db->like('first_name', $name,'after'); $this->db->like('phone_number', $phone,'after'); // $this->db->limit($limit,$start); //calculating total number of pages

// $this->db->limit($limit); $this->db->order_by($sidx,$sord); $query = $this->db->get(); return $query->result(); } function getAllSearchU($name,$phone,$limit,$sidx,$sord,$start){ $this->db->select('id,first_name,phone_number,mobile'); $this->db->from('user'); //$this->db->where('first_name',$name); //$this->db->or_where('phone_number',$phone); //$array = array('first_name' => $name, 'phone_number' => $phone); // $this->db->where($array); $this->db->like('first_name', $name,'after'); $this->db->like('phone_number', $phone,'after'); $this->db->limit($limit,$start); // $this->db->limit($limit); $this->db->order_by($sidx,$sord); $query = $this->db->get(); return $query->result(); } 26 sept 1)Client and server side length validations to user signup signup mail to admin few labels corrected. After login --> redirect to homepage session variable username was not getting value...corrected... function sellnotes(){ $this->load->helper(array('form', 'url','array')); $this->load->library('form_validation'); $this->load->Model('user_model'); $this->data['notes_state'] = $this->user_model->getStates(); // default school data dependent on state $this->data['notes_state_school'] = $this->user_model->getstateschooldata(1);

$config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $this->load->library('upload', $config);

$this->form_validation->set_rules('notesname', 'Notes Name', 'required|xss_clean'); $this->form_validation->set_rules('notes_state', 'Notes State', 'required|xss_clean'); $this->form_validation->set_rules('notes_school', 'Notes School', 'required|xss_clean'); $this->form_validation->set_rules('course', 'course', 'required|xss_clean'); $this->form_validation->set_rules('professor', 'professor', 'required|xss_clean'); $this->form_validation->set_rules('paypalid', 'Paypal Id', 'required|xss_clean'); if($this->input->post('submit')) { $tmp=$_FILES['upload']['tmp_name']; $dest=$_FILES['upload']['name']; $str=explode('.',$dest); $pre= $str['0'].time(); $pre1=$str['1']; $dest=$pre.'.'.$pre1; if(move_uploaded_file($tmp ,'./uploads/'.$dest )){ $flag=1; }else{ $this->session->set_flashdata('error','Some problem to file upload'); } } $this->upload->data(); if($this->input->post('submit')){ if($this->form_validation->run()==True){ $userid = $this->session->userdata['login_id']; $notes_detail=array( 'user_id'=>$userid, 'notes_name'=>$this->input->post('notesname'), 'notes_file'=>$dest, 'notes_desc'=>$this->input->post('notesdesc'), 'notes_state'=>$this->input->post('notes_state'), 'notes_school'=>$this->input->post('notes_school'), 'course'=>$this->input->post('course'), 'professor'=>$this->input->post('professor'), 'paypal_email'=>$this->input->post('paypalid'), 'created_on'=>date('Y-m-d H:i:s'), 'updated_on'=>date('Y-m-d H:i:s') ); $udata=array( 'user_id'=>$userid, 'notes_name'=>$this->input->post('notesname') ); $query=$this->db->get_where('notes',$udata); $num=$query->num_rows(); if($num>0){ $this->session->set_flashdata('notice','Notes name already exists');

} else{ $this->db->insert('notes',$notes_detail); if($flag==1){ $this->session->set_flashdata('notice','Notes uploaded susccessfully'); } } } } $this->render('home'); }

A user can recommend a comment single time....A database entry should be there to check userid against comment recommend. How many times an individual user can post comment over a note ???is that once or any other limitation???

We are having a listing of comments for a single note. These comments are made by different unique users.For each comment a single user can recommend it once. Hence for each comment there will be many recommendations by diff users. Then how will i distinguish that a single user has made comment when he is recommending the previus comment again?? SELECT comments.`notes_id` , user_comments.user_id FROM comments INNER JOIN user_comments ON comments.id = user_comments.comments_id WHERE comments.`notes_id` =4 and user_comments.user_id=32 SELECT sum(user_comments.recommend) from comments inner join user_comments on comments.id = user_comments.comments_id where comments.notes_id=4 and user_comments.user_id=32

<!--open pop up report abuse--> <div id="shadowing"></div> <div id="box"> <span id="boxtitle"></span> <?php $attr=array( 'name'=>'abusecomments', 'id'=>'abusecomments', 'target'=>'_parent' ); echo form_open('/index/notesdetail/',$attr);?>

<!-- <form method="POST" action="/index/notesdetail/" target="_parent">--> <p>Abuse Text <!-<input type="text" name="abusetext" id="abusetext" value="" size="60">--> <?php $data=array( 'name'=>'abusetext', 'id'=>'abusetext', 'size'=>'60' ); echo form_input($data); ?> </p> <!-- <input type="hidden" name="notes_comment_id" id="notes_comment_id">--> <?php $data=array( 'name'=>'notes_comment_id', 'id'=>'notes_comment_id' ); echo form_hidden($data); ?> <!--<input type="hidden" name="notes_id" id="notes_id" value="<?php echo $notesinfo['notes_id']; ?>" >--> <?php $data=array( 'name'=>'notes_id', 'id'=>'notes_id' ); echo form_hidden($data); ?> <p> <!-<input type="submit" name="submitabuse" value="Submit Abuse Text">--> <?php $data=array( 'name'=>'submitabuse', 'value'=>'Submit Abuse Text' ); echo form_submit($data); ?> <!-<input type="button" name="cancel" value="Cancel" onClick="closebox()">--> <?php $data=array( 'name'=>'cancel', 'value'=>'Cancel' ); $js="onClick='closebox()'"; echo form_button($data,$js); ?> </p> <?php echo form_close(); ?> </div> function abusenotes() { $this->load->helper(array('form', 'url')); echo $comment_id= $this->input->get('comment_id'); echo $notes_id= $this->input->get('notes_id'); $notescommentinfo=array( 'comment_id'=>$comment_id,

'notes_id' =>$notes_id ); $this->load->view('index/abusenotes_form.tpl.php',$notescommentinfo,true); //$this->render('front_Layout_Login'); } function abusenotes_form() { $this->load->helper(array('form', 'url')); $this->load->Model('user_model'); $this->render('front_Layout_Login'); } <a class='example5' href="/index/abusenotes?comment_id=<?php echo $val->id; ?>& notes_id=<?php echo $notesinfo['notes_id']; ?>" >Report abuse</a>

Anda mungkin juga menyukai