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.

date_range()

date_range([$unix_start = ''[, $mixed = ''[, $is_unix = TRUE[, $format = 'Y-m-d']]]]) Parameters: $unix_start (int) – UNIX timestamp of the range start date $mixed (int) – UNIX timestamp of the range end date or interval in days $is_unix (bool) – set to FALSE if $mixed is not a timestamp $format (string) – Output date format, same as in date() Returns: An array of dates Return type: array Returns a list of dates within a specified period. Example: $range = date_range('2012-01-01

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 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 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 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

current_url()

current_url() Returns: The current URL Return type: string Returns the full URL (including segments) of the page being currently viewed. Note Calling this function is the same as doing this: | | site_url(uri_string());

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