days_in_month()

days_in_month([$month = 0[, $year = '']]) Parameters: $month (int) – a numeric month $year (int) – a numeric year Returns: Count of days in the specified month Return type: int Returns the number of days in a given month/year. Takes leap years into account. Example: echo days_in_month(06, 2005); If the second parameter is empty, the current year will be used. Note This function will alias the native cal_days_in_month(), if it is available.

delete_cookie()

delete_cookie($name[, $domain = ''[, $path = '/'[, $prefix = '']]]) Parameters: $name (string) – Cookie name $domain (string) – Cookie domain (usually: .yourdomain.com) $path (string) – Cookie path $prefix (string) – Cookie name prefix Return type: void Lets you delete a cookie. Unless you’ve set a custom path or other values, only the name of the cookie is needed. delete_cookie('name'); This function is otherwise identical to set_cookie(), except that it does not have the value a

Database Metadata

Table MetaData These functions let you fetch table information. List the Tables in Your Database $this->db->list_tables(); Returns an array containing the names of all the tables in the database you are currently connected to. Example: $tables = $this->db->list_tables(); foreach ($tables as $table) { echo $table; } Determine If a Table Exists $this->db->table_exists(); Sometimes it’s helpful to know whether a particular table exists before running an operation on it.

Database Quick Start: Example Code

The following page contains example code showing how the database class is used. For complete details please read the individual pages describing each function. Initializing the Database Class The following code loads and initializes the database class based on your configuration settings: $this->load->database(); Once loaded the class is ready to be used as described below. Note: If all your pages require database access you can connect automatically. See the connecting page for details

Database Reference

CodeIgniter comes with a full-featured and very fast abstracted database class that supports both traditional structures and Query Builder patterns. The database functions offer clear, simple syntax. Quick Start: Usage Examples Database Configuration Connecting to a Database Running Queries Generating Query Results Query Helper Functions Query Builder Class Transactions Getting MetaData Custom Function Calls Query Caching Database Manipulation with Database Forge Databa

Database Configuration

CodeIgniter has a config file that lets you store your database connection values (username, password, database name, etc.). The config file is located at application/config/database.php. You can also set database connection values for specific environments by placing database.php in the respective environment config folder. The config settings are stored in a multi-dimensional array with this prototype: $db['default'] = array( 'dsn' => '', 'hostname' => 'localhost',

Database Caching Class

The Database Caching Class permits you to cache your queries as text files for reduced database load. Important This class is initialized automatically by the database driver when caching is enabled. Do NOT load this class manually. Important Not all query result functions are available when you use caching. Please read this page carefully. Enabling Caching Caching is enabled in three steps: Create a writable directory on your server where the cache files can be stored. Set the path to your

Custom Function Calls

$this->db->call_function(); This function enables you to call PHP database functions that are not natively included in CodeIgniter, in a platform independent manner. For example, let’s say you want to call the mysql_get_client_info() function, which is not natively supported by CodeIgniter. You could do so like this: $this->db->call_function('get_client_info'); You must supply the name of the function, without the mysql_ prefix, in the first parameter. The prefix is added automatic

Creating Libraries

When we use the term “Libraries” we are normally referring to the classes that are located in the libraries directory and described in the Class Reference of this user guide. In this case, however, we will instead describe how you can create your own libraries within your application/libraries directory in order to maintain separation between your local resources and the global framework resources. As an added bonus, CodeIgniter permits your libraries to extend native classes if you simply need

create_captcha()

create_captcha([$data = ''[, $img_path = ''[, $img_url = ''[, $font_path = '']]]]) Parameters: $data (array) – Array of data for the CAPTCHA $img_path (string) – Path to create the image in $img_url (string) – URL to the CAPTCHA image folder $font_path (string) – Server path to font Returns: array(‘word’ => $word, ‘time’ => $now, ‘image’ => $img) Return type: array Takes an array of information to generate the CAPTCHA as input and creates the image to your specifications