Showing posts with label Codeigniter. Show all posts
Showing posts with label Codeigniter. Show all posts

Mysql Join query Codeigniter

Mysql Join query Codeigniter code loads and initializes the database class based on your configuration settings. $query = $this->db->query('SELECT name, title, email FROM my_table'); foreach ($query->result() as $row) {     echo $row->title;     echo $row->name;     echo $row->email; } echo 'Total Results: ' . $query->num_rows();  Mysql Join query ...

Checking the values of the form-codeigniter

Checking the values of the form-codeigniter We need to ensure that all of the form fields have been filled in. We can do this by simply using the empty()PHP function. Before we do this, we want to assign the value of the form fields to variables. This makes it easy for us by saving us from having to type out $this->input->post('name')every time. Here's the code for this; it should be placed inside the ifstatement where the comment //...

Top codeigniter interview question and answers

codeigniter interview question  What is codeigniter? Codeigniter is open source , web application framework.Its is for building websites using php.Codeigniter is loosely based on MVC pattern.Most simple framework in php , which is you will easily learn.Its mostly known for its speed as compare to other frameworks in php. Its goal is to enable you to develop projects much faster than you could if you were writing code from scratch, by providing...

codeigniter-Creating loops

Creating loops in view files has been a stumbling block for a few developers. By passing a multidimensional array to a view file, you can easily establish a loop in any of your view files. Let's take a look at an example.<?phpclass Todo extends Controller{function index(){$data['todo_list'] = array("buy food", "clean up", "mow lawn");$this->load->view('todo', $data);}}?>This is a very simple Controller. Your view file for this would...

CodeIgniter models

All CodeIgniter models have the same initial structure: < ?phpclass Page_model extends Model{function Page_model(){parent::Model();}}? > The first function is the code that retrieves the home page < ?phpclass Page_model extends Model{function Page_model(){parent::Model();}function fetchHomePage(){$data = array();$options = array(‘status’ = > ‘live’, ‘type’= > ‘home’);$q = $this- > db- > getwhere(‘pages’, $options, 1);if...

Let's Make A Master Template codeigniter

A simple CSS file, it ’ s time to create a generic Template view that you can reuse throughout your application. In this master template, which you can name template.php, are a series of embedded PHP calls that load certain subviews, such as header, navigation, and footer. These subviews contain the HTML and PHP that you will create in the  next few sections. Notice in the following code that you ’ re also trying to load a subview with...

what is CodeIgniter Helpers?

Helpers, as their name implies, help you with specific tasks. Unlike libraries, helpers are not object -oriented but procedural in nature. Each helper contains one or more functions, each focusing on a specific task, with zero dependence on other functions. Helpers can either be loaded locally or autoloaded in /system/application/config/autoload.php. CodeIgniter's  helpers: Array —  The   Array helpercontains functions that...

Codeigniter Database Library

The  Database librarycontains a series of helpful functions that make it easy for you to create and run queries and process the result sets from those queries. The first thing to note about the Database library in CodeIgniter is that it allows you to pass in simple SQL queries. At the end of the day, many people who are new to CodeIgniter find this to be a great comfort. Although some of the built - in Active Record patterns provide helpful...

codeigniter routes page

The  routes.php filelets you remap URI requests to specific controller functions. For example, you may have a controller named sitewith a function named index. The URI for this controller/function combination might be: http://www.example.com/site/index Furthermore, if your site controller had a pagesfunction that accepted a numeric ID for database lookup, the URI might look like this: http://www.example.com/site/pages/4 In some cases,...

e-mail parameters-Codeigniter

The next thing that we will need to do is to set our e-mail parameters, the sender, the recipient, any e-mail address to send a carbon copy or blind carbon copy to, the subject of our e-mail, and the message body. Take a look at the following code and see if you can distinguish the different parts of our e-mail: $this->email->from('you@example.com', 'Your Name');$this->email->to('someone@example.com');$this->email->cc('another@person.com');$this->email->bcc('theboss@example.com');$this->email->subject('Email...

Retrieving data-Codeigniter

Retrieving POST data Toretrieve post data, you should use the function shown next. The first parameter is the name of the POST item that you are looking for.$this->input->post('some_field'); This function returns the item it if exists, and returns FALSE if it does not. The second function lets you run the data through the XSS filter without writing any more code. This is an easier way of running the XSS filter on a per-item basis.$this->input->post('some_field',...

CodeIgniter system Folder

The system/ folder is where all the action happens. This folder contains all the CodeIgniter code of consequence, organized into various folders: application —  The   application foldercontains the application you ’ re building. Basically, this folder contains your models, views, controllers, and other code (like helpers and class extensions). In other words, this folder is where you ’ ll do 99 percent of your work. cache —  The   cache foldercontains all cached pages for your application. In Chapter 9 , you...

CodeIgniter config.php

The  config.php filecontains a series of configuration options all of them stored in a PHP array called, appropriately enough, $config) that CodeIgniter uses to keep track of your application ’ s  information and settings. The first configuration option you need to set inside config.php is the base URL of your application. You do that by setting the absolute URL (including the http:// part) for $config[ ‘ base_url ’ ], like so: $config[‘base_url’] = “http://www.example.com/test/”; Once  you ’ ve set this configuration option,...

Codeigniter count_all for pagination

work on count_all condition.. you can use below method to find out total number of rows.. public function count_all() { $this->db->select ( 'COUNT(*) AS `numrows`' ); $this->db->where ( array ( 'type' => 'Original' ) ); $query = $this->db->get ( 'story_tbl' ); return $query->row ()->numrows; } ou could also use the built-in num_rows() function... $query = $this->db->where('type', 'original')->get('story_tbl'); return $query->num_rows();...