read_file()

read_file($file) Parameters: $file (string) – File path Returns: File contents or FALSE on failure Return type: string Returns the data contained in the file specified in the path. Example: $string = read_file('./path/to/file.php'); The path can be a relative or full server path. Returns FALSE (boolean) on failure. Note The path is relative to your main site index.php file, NOT your controller or view files. CodeIgniter uses a front controller so paths are always relative to the m

Query Helper Methods

Information From Executing a Query $this->db->insert_id() The insert ID number when performing database inserts. Note If using the PDO driver with PostgreSQL, or using the Interbase driver, this function requires a $name parameter, which specifies the appropriate sequence to check for the insert id. $this->db->affected_rows() Displays the number of affected rows, when doing “write” type queries (insert, update, etc.). Note In MySQL “DELETE FROM TABLE” returns 0 affected rows. The

Profiling Your Application

The Profiler Class will display benchmark results, queries you have run, and $_POST data at the bottom of your pages. This information can be useful during development in order to help with debugging and optimization. Initializing the Class Important This class does NOT need to be initialized. It is loaded automatically by the Output Library if profiling is enabled as shown below. Enabling the Profiler To enable the profiler place the following line anywhere within your Controller methods: $t

Queries

Query Basics Regular Queries To submit a query, use the query function: $this->db->query('YOUR QUERY HERE'); The query() function returns a database result object when “read” type queries are run, which you can use to show your results. When “write” type queries are run it simply returns TRUE or FALSE depending on success or failure. When retrieving data you will typically assign the query to your own variable, like this: $query = $this->db->query('YOUR QUERY HERE'); Simplified Qu

prep_url()

prep_url($str = '') Parameters: $str (string) – URL string Returns: Protocol-prefixed URL string Return type: string This function will add http:// in the event that a protocol prefix is missing from a URL. Pass the URL string to the function like this: $url = prep_url('example.com');

password_needs_rehash()

password_needs_rehash() Parameters: $hash (string) – Password hash $algo (int) – Hashing algorithm $options (array) – Hashing options Returns: TRUE if the hash should be rehashed to match the given algorithm and options, FALSE otherwise Return type: bool For more information, please refer to the PHP manual for password_needs_rehash().

plural()

plural($str) Parameters: $str (string) – Input string Returns: A plural word Return type: string Changes a singular word to plural. Example: echo plural('dog'); // Prints 'dogs'

PHP Style Guide

The following page describes the coding styles adhered to when contributing to the development of CodeIgniter. There is no requirement to use these styles in your own CodeIgniter application, though they are recommended. Table of Contents PHP Style Guide File FormatTextMate BBEdit PHP Closing Tag File Naming Class and Method Naming Variable Names Commenting Constants TRUE, FALSE, and NULL Logical Operators Comparing Return Values and Typecasting Debugging Code Whitespace in Files Compatibilit

password_verify()

password_verify($password, $hash) Parameters: $password (string) – Plain-text password $hash (string) – Password hash Returns: TRUE if the password matches the hash, FALSE if not Return type: bool For more information, please refer to the PHP manual for password_verify().

parse_smileys()

parse_smileys([$str = ''[, $image_url = ''[, $smileys = NULL]]]) Parameters: $str (string) – Text containing smiley codes $image_url (string) – URL path to the smileys directory $smileys (array) – An array of smileys Returns: Parsed smileys Return type: string Takes a string of text as input and replaces any contained plain text smileys into the image equivalent. The first parameter must contain your string, the second must contain the URL to your smiley folder Example: $str = 'He