Search Results

Search found 981 results on 40 pages for 'codeigniter 2'.

Page 16/40 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Load a model in a Codeigniter library

    - by ci
    Hello, people! I have this piece of code: class MY_Language extends CI_Language { function MY_Language() { parent::CI_Language(); $CI =& get_instance(); $CI->load->model('language_model'); $languages = $this->language_model->get_languages(); print_r($languages); } } But I keep getting "Fatal error: Call to undefined function get_instance() in C:\xampp\htdocs\application\libraries\MY_Language.php on line 44". Any ideas? Thanks in advance!

    Read the article

  • codeigniter - pass all form values to model

    - by Patrick
    I have a registration form that collects several parameters. i need to pass all these AND a confirmation code (generated by the controller) to the model for inserting in the DB. How can I do that? is there a way to pass the whole post to the model, eg like $this->model->insert($this->input->form(), $confirmation_code)?

    Read the article

  • Pass codeigniter translation array to jQuery Function

    - by grolle
    Hi, I’ve a problem by passing an array to a jQuery function. Some code: // in the language file $lang['daynames'] = array('So','Mo','Di','Mi','Do','Fr','Sa'); //In the view var config = { basePath : '' }; // THIS WORKS GREAT!!! var days = new array('lang-line('daynames')); ?'); //in the js-File $(function() { $("#datepicker").datepicker({ dateFormat : 'dd.mm.yy', showWeek : true, firstDay : 1, weekHeader : 'KW', dayNamesMin : days, monthNames : ['Januar','Februar','März','April', 'Mai','Juni','Juli','August','September', 'Oktober','November','Dezember'], onSelect : function(dateText,inst){ } }); }); If I do lang-line(‘daynames’)); ? in the view everything looks fine, so what is wrong here? Thanks and best regards ...

    Read the article

  • Codeigniter: URI segments

    - by Kevin Brown
    How do I create an if statement saying something like this? $segment = "segment 2 or 3"; if($segment == 1{ do stuff } I know this is pretty elementary, but I don't totally understand the URI class...

    Read the article

  • CodeIgniter static class question

    - by Josh K
    If I would like to have several static methods in my models so I can say User::get_registered_users() and have it do something like public static function get_registered_users() { $sql = "SELECT * FROM `users` WHERE `is_registered` = 0"; $this->db->query($sql); // etc... } Is it possible to access the $this->db object or create a new one for a static method?

    Read the article

  • photo upload with codeigniter

    I know there are many tutorials online, but I could not make them work :( maybe something particularly wrong with my system :/ My Controller localpath is: /localhost/rl/applications/backend/controller/ Controller: function do_upload() { $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); if ( ! $this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); $this->load->view('add_image', $error); } else { $data = array('upload_data' => $this->upload->data()); $data['id'] = $this->input->post['id_work']; $this->load->view('add_image', $data); } } My View localpath is: /localhost/rl/applications/backend/view/ View: echo form_open_multipart('do_upload'); <ul class="frm"> <li><label>File: *</label><input type="file" name="userfile" class="frmlmnt" size="50" /></li> <li><label></label><input type="submit" class="btn" value="Upload" /></li> </ul> </form> Maybe I do something wrong with path

    Read the article

  • Codeigniter: Check where model is loaded from?

    - by qwerty
    I'm having the strangest thing ever right now. I "disabled" a model because i don't need to access it ever again. I did so by echoing out an error string in the __construct() and right after that die(). That way i would notice if i ever loaded the model, even by mistake, which should never happen. Alright? The problem is, the model is not loaded ANYWHERE in the entire project, but it still gets loaded for some reason. It's not auto loaded, that's for sure. Is it possible to track down where a model is loaded? Like which line it happens etc?

    Read the article

  • Display error when entire form is blank in CodeIgniter

    - by Joe
    I'm trying to create a fairly simple form that has a few checkboxes and input fields and a textarea. Nothing is required by itself; however, if 'A' checkbox is checked, then 'A' input field is required (and so on for the couple other checkboxes I have). I have the above functionality in place, but I'm having a tough time figuring out how to have an error returned if the form is submitted blank (since nothing is required by default). Does anyone know of an easy-ish solution for this? It seems like it should be so simple... Thanks

    Read the article

  • CodeIgniter URI segments captured as variables?

    - by Zen Savona
    well, i have a function within a controller called test, and i can access it by going to http://localhost/nwk/control/test this is my function. I want to use the data given in the next segment from the "test" as a php variable. so if i put function test() { $var $this->uri->segment(3); echo $var; } according to the user guide if I enter control/test/data, my variable should be equal to 'data'? doesn't seem to be working. Am I missing something here?

    Read the article

  • Codeigniter view file looping query

    - by user2505513
    Right, I'm unsure about how to code my view file to generate following query results WITHOUT compromising the principles of mvc. Query in model: SELECT * FROM events GROUP BY country, area ORDER BY country, area View: <?php if (isset($query)):?> <?php foreach ($query as $row):?> <h2><?=$row->country?></h2> <h3><?=$row->area?></h3> <?php endforeach;?> <?php endif;?> I want the results to display: England North South West - utilising the GROUP BY parameter As opposed to: England North England South England West Has anybody any advice as to how to achieve this?

    Read the article

  • CodeIgniter -- unable to use an object

    - by Smandoli
    THE SUMMARY: When I call .../index.php/product, I receive: Fatal error: Call to a member function get_prod_single() on a non-object in /var/www/sparts/main/controllers/product.php on line 16 The offending Line 16 is: $data['pn_oem'] = $this->product_model->get_prod_single($product_id); Looks like I don't know how to make this a working object. Can you help me? THE CODE: In my /Models folder I have product_model.php: <?php class Product_model extends Model { function Product_model() { parent::Model(); } function get_prod_single($product_id) { //This will be a DB lookup ... return 'foo'; //stub to get going } } ?> In my /controllers folder I have product.php: <?php class Product extends Controller { function Product() { parent::Controller(); } function index() { $this->load->model('Product_model'); $product_id = 113; // will get this dynamically $data['product_id'] = $product_id; $data['pn_oem'] = $this->product_model->get_prod_single($product_id); $this->load->view('prod_single', $data); } } ?>

    Read the article

  • Codeigniter: how should I restructure db schema?

    - by Kevin Brown
    I don't even know if that's the right term. May it be known that I'm a major novice! I have three tables: users, profiles, and survey. Each one has user_id as it's first field, (auto-increment for users), and they're all tied by a foreign key constraint, CASCADE on DELETE. Currently, for each user, let's say user_id 1, they have a corresponding db entry in the other tables. For profiles it lists all their information, and the survey table holds all their survey information. Now I must change things...darn scope creep. Users need the ability to have multiple survey results. I imagine that this would be similar to a comment table for a blog... My entire app runs around the idea that a single user is linked to a constraining profile and survey. How should I structure my db? How should I design my app's db so that a user can have multiple tests/profiles for the test? Please assist! Any advice, information and personal-knowledge is appreciated! Right now the only way I know how to accompany my client is to create a pseudo-user for each test (so unnecessary) and list them in a view table (called "your tests")-- these are obtained from the db by saying: where user_id=manager_id

    Read the article

  • MySQL Queries using Doctrine & CodeIgniter

    - by 01010011
    Hi, How do I write plane SQL queries using Doctrine connection object and display the results? For example, how do I perform: SELECT * FROM table_name WHERE column_name LIKE '%anything_similar_to_this%'; using Doctrine something like this (this example does not work) $search_key = 'search_for_this'; $conn = Doctrine_Manager::connection(); $conn->execute('SELECT * FROM table_name WHERE column_name LIKE ?)', $search_key); echo $conn;

    Read the article

  • Passing arguments and conditions to model in codeigniter

    - by stormdrain
    I'm adding some models to a project, and was wondering if there is a "best practice" kind of approach to creating models: Does it make sense to create a function for each specific query? I was starting to do this, then had the idea of creating a generic function that I could pass parameters to. e.g: Instead of function getClients(){ return $this->db->query('SELECT client_id,last FROM Names ORDER BY id DESC'); } function getClientNames($clid){ return $this->db->query('SELECT * FROM Names WHERE client_id = '.$clid); } function getClientName($nameID){ return $this->db->query('SELECT * FROM Names WHERE id ='.$nameID); } } Something like function getNameData($args,$cond){ if($cond==''){ $q=$this->db->query('SELECT '.$args.' FROM Names'); return $q; }else{ $q=$this->db->query('SELECT '.$args.' FROM Names WHERE '.$cond); return $q; } } where I can pass the fields and conditions (if applicable) to the model. Is there a reason the latter example would be a bad idea? Thanks!

    Read the article

  • CodeIgniter - the right way to create "block" elements on web page

    - by kikkoman90
    Hello. I've been searching for a solutions for this problem a while but haven't seen any "valid mvc" solution for this. I hope I can explain my problem clearly enough for you guys. I need to create a dynamic block of HTML on my website. (eg. a block containing user's latest blog comments). I have a template view file (a file containing header, content container and a footer) where I need to add some content AND this block element. The problem is that I don't want to duplicate this block code on every controller. It just feels stupid and I'm sure there's a better way to do this than just duplicating same stuff all over again on all the controller files? I can add view inside another view just fine, but what bugs me is how to actually generate that dynamic content to this block's view-file. I can't call controller from view file, controller from controller filem or model from view file because what I understand that just isn't the "mvc" way? Anyone got any tricks or tips for this?

    Read the article

  • codeigniter differentiate field names in JOINed tables

    - by Patrick
    Hi, I need to retrieve data from two tables. the first is a list of events, the second is a list of venues. I have a fields with the same name in both tables: events.venue (which is an ID) and venues.venue is the name of the place, say "blues bar". The tables can be joined on events.venue = venues.id. Snippet of my model: $this->db->select('events.*, venues.*'); $this->db->join('venues', 'events.venue = venues.id'); if ($date != 'all') { $this->db->where('date', $date); } if ($keyword) { $this->db->like('description', $keyword); $this->db->or_like('band', $keyword); $this->db->or_like('venue', $keyword); $this->db->or_like('genre', $keyword); } $Q = $this->db->get('events'); if ($Q->num_rows() > 0) { foreach ($Q->result() as $row) { $data[] = $row; } } $Q->free_result(); return $data; Snippet of the View: foreach ($events as $row) { echo "<p>{$row->band} ({$row->genre})<br />"; echo "Playing at: {$row->venue}<br /></p>"; // echoes "blues bar" //more here... } 2 Questions: 1) Why does $row-venue echo venues.venue, instead of events.venue? B) how can I differentiate them? eg. What if I want to echo both events.venue and venues.venue? I can probably do something like "SELECT venues.venue as name_of_the_venue", but how can I do this when I've already selected *?

    Read the article

  • Codeigniter - Active record - sql - complex join

    - by Jack
    I have a function that retrieves all tags from a table: function global_popular_tags() { $this->db->select('tags.*, COUNT(tags.id) AS count'); $this->db->from('tags'); $this->db->join('tags_to_work', 'tags.id = tags_to_work.tag_id'); $this->db->group_by('tags.id'); $this->db->order_by('count', 'desc'); $query = $this->db->get()->result_array(); return $query; } I have another table called 'work'. The 'work' table has a 'draft' column with values of either 1 or 0. I want the COUNT(tags.id) to take into account whether the work with the specific tag is in draft mode (1) or not. Say there are 10 pieces of work tagged with, for example, 'design'. The COUNT will be 10. But 2 of these pieces of work are in draft mode, so the COUNT should really be 8. How do I manage this?

    Read the article

  • Logging in to Wordpress through CodeIgniter DX Authentication

    - by whobutsb
    Hello All, I'm about to start a very large project of rebuilding my companies intranet. The plan is to have most of the intranet live in a CI application. I chose to use CI because i'm very familiar with all the CI methods. Some sections of the intranet are going to be wordpress blogs. For example the Human Resources Dept. and the Marketing Dept will have their own wordpress blogs. Ideally my plan is to log on to the intranet, with a CI authentication library like DXAuth by querying the Active Directory of the company. When I return the AD information for the user I will by saving their group memberships into a session. It would be fantastic if I could have that session information of the user be used by wordpress to log the user as an editor if they are a member of the Marketing Group. And allow users who are not members of the group be able to comment on that blog, with out logging into wordpress. My question is if there are any CI classes or Wordpress Plugins, or tutorals out there, of this sort of integration with the two systems. Thank you for your help!

    Read the article

  • Codeigniter: validation problem

    - by krike
    For some reason a user can login with any password, first I thought I forgot to check for the password but I didn't... and I just cant find the problem here is the model: /*#######################################################*/ function validate() /*#######################################################*/ { $this->db->where('username', $this->input->post('username')); $this->db->where('password', md5($this->input->post('password'))); $q = $this->db->get('user_extra'); if($q->num_rows() == 1): return true; else: return false; endif; }//end of function validate() The controller /*#######################################################*/ function validate_credentials() /*#######################################################*/ { $this->load->model('membership_model'); $this->load->library('form_validation'); $this->form_validation->set_rules('username', 'Name', 'trim|required'); $this->form_validation->set_rules('password', 'password', 'trim|required'); if(!$this->membership_model->validate()): $this->form_validation->set_message('check_login', 'Login not correct, please try again.'); endif; if($this->form_validation->run() == FALSE): $this->index(); else: $this->membership_model->userinfo($this->input->post('username')); //should redirect to last view redirect($this->session->flashdata('redirect_url')); endif; }// end of validate_credentials()

    Read the article

  • CodeIgniter: help with this query

    - by iamjonesy
    Hi, I have just started my first CI app. I have a view that displays some posts. Each post can have multiple comments and I want to display the total number of comments next to each post. So far all my db call are in my controller (will be changing this). function index(){ $data['query'] = $this->db->get('posts'); $this->load->view('blog_view', $data); } In my view: <?php foreach($query->result() as $row): <div class="post-box"> <p><?php echo $row->body; ?><small>&nbsp;added by <?php echo $row->username; ?> on <?php echo date ('d/m/Y',strtotime($row->created)); ?>&nbsp;<a href="<?php echo base_url(); ?>blog/comments/<?php echo $row->id; ?>"><img src="<?php echo base_url(); ?>images/comments_icon.png" />&nbsp;0</a></small></p> </div> <?php endforeach; ?> I want to get the total number of comments where comment.post_id = the current record's id. and display it next to the comments icon. Any help with this most appreciated, Billy

    Read the article

  • Codeigniter: user defined helper function does not load.

    - by cbrandolino
    Hi everybody. I made a custom helper extending the system string_helper.php. I placed it in my /application/helpers folder, called MY_string_helper.php as required, unit-tested its functions. Now, when I try to call one of its functions from a model, it does not work. The functions in the default string helper work, instead. It looks like my extension is not loaded for some reasons. Thanks a lot, and happy holidays.

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >