CAFPE Docs
  • Class

Classes

  • Article_model
  • Articles
  • Auth
  • Auth_controller
  • Bcrypt
  • Hierarchical_controllers
  • Ion_auth
  • Ion_auth_model
  • MY_Controller
  • MY_Lang
  • MY_Model
  • Pages
  • Private_pages
  • Public_controller
  • Seeder
  • Slug
  • User_sessions
  • Users

Functions

  • action_result
  • actions_widget
  • admin_area_buttons
  • base64_current_url_encode
  • base64_url_decode
  • base64_url_encode
  • current_lang
  • jscript_tag
  • lang_switcher
  • logged_in
  • redirect_lang
  • site_url_lang
  • style_tag

Class Article_model

how to extend MY_Model: class User_model extends MY_Model { public $table = 'users'; // Set the name of the table for this model. public $primary_key = 'id'; // Set the primary key public $fillable = array(); // You can set an array with the fields that can be filled by insert/update public $protected = array(); // ...Or you can set an array with the fields that cannot be filled by insert/update public function __construct() { $this->database_connection = group_name or array() | OPTIONAL Sets the connection preferences (group name) set up in the database.php. If not trset, it will use the 'default' (the $active_group) database connection. $this->timestamps = TRUE | array('made_at','modified_at','removed_at') If set to TRUE tells MY_Model that the table has 'created_at','updated_at' (and 'deleted_at' if $this->soft_delete is set to TRUE) If given an array as parameter, it tells MY_Model, that the first element is a created_at field type, the second element is a updated_at field type (and the third element is a deleted_at field type) $this->soft_deletes = FALSE; Enables (TRUE) or disables (FALSE) the "soft delete" on records. Default is FALSE $this->timestamps_format = 'Y-m-d H:i:s' You can at any time change the way the timestamp is created (the default is the MySQL standard datetime format) by modifying this variable. You can choose between whatever format is acceptable by the php function date() (default is 'Y-m-d H:i:s'), or 'timestamp' (UNIX timestamp) $this->return_as = 'object' | 'array' Allows the model to return the results as object or as array $this->has_one['phone'] = 'Phone_model' or $this->has_one['phone'] = array('Phone_model','foreign_key','local_key'); $this->has_one['address'] = 'Address_model' or $this->has_one['address'] = array('Address_model','foreign_key','another_local_key'); Allows establishing ONE TO ONE or more ONE TO ONE relationship(s) between models/tables $this->has_many['posts'] = 'Post_model' or $this->has_many['posts'] = array('Posts_model','foreign_key','another_local_key'); Allows establishing ONE TO MANY or more ONE TO MANY relationship(s) between models/tables $this->has_many_pivot['posts'] = 'Post_model' or $this->has_many_pivot['posts'] = array('Posts_model','foreign_primary_key','local_primary_key'); Allows establishing MANY TO MANY or more MANY TO MANY relationship(s) between models/tables with the use of a PIVOT TABLE !ATTENTION: The pivot table name must be composed of the two table names separated by "" the table names having to to be alphabetically ordered (NOT users_posts, but posts_users). Also the pivot table must contain as identifying columns the columns named by convention as follows: table_name_singular + _ + foreign_table_primary_key. For example: considering that a post can have multiple authors, a pivot table that connects two tables (users and posts) must be named posts_users and must have post_id and user_id as identifying columns for the posts.id and users.id tables. $this->cache_driver = 'file' $this->cache_prefix = 'mm' If you know you will do some caching of results without the native caching solution, you can at any time use the MY_Model's caching. By default, MY_Model uses the files to cache result. If you want to change the way it stores the cache, you can change the $cache_driver property to whatever CodeIgniter cache driver you want to use. Also, with $cache_prefix, you can prefix the name of the caches. by default any cache made by MY_Model starts with 'mm' + _ + "name chosen for cache" $this->delete_cache_on_save = FALSE If you use caching often and you don't want to be forced to delete cache manually, you can enable $this->delete_cache_on_save by setting it to TRUE. If set to TRUE the model will auto-delete all cache related to the model's table whenever you write/update/delete data from that table. $this->pagination_delimiters = array('',''); If you know you will use the paginate() method, you can change the delimiters between the pages links $this->pagination_arrows = array('<','>'); You can also change the way the previous and next arrows look like.

parent::__construct(); } }

CI_Model
Extended by MY_Model
Extended by Article_model
Located at Article_model.php

Methods summary

public
# __construct( )

Overrides

MY_Model::__construct
public
# get_all_lang( string $lang, $order_by = '' )

returns all articles with fields in given language

returns all articles with fields in given language

Parameters

$lang
language
$order_by

Returns


$this
public
# where_slug( string $slug, string $lang = '' )

add where clause to get slug in given language. If not language provided searches in all slug fields

add where clause to get slug in given language. If not language provided searches in all slug fields

Parameters

$slug
slug
$lang
language

Returns


$this
public mixed
# slug_lang( string $slug )

looks for a slug in DB, if it's found, returns its lang

looks for a slug in DB, if it's found, returns its lang

Parameters

$slug
slug

Returns

mixed
lang or false, if not found
protected array
# create_slugs( array $data )

Creates data slugs from titles

Creates data slugs from titles

Parameters

$data
original data

Returns

array
$data modified data
protected array
# get_main_pic( array $data )

Gets first picture in an article

Gets first picture in an article

Parameters

$data
original data

Returns

array
$data modified data
protected array
# date_toggle( array $data )

Toggles date in array of result(s) from DB

Toggles date in array of result(s) from DB

Parameters

$data
original data

Returns

array
$data modified data

Methods inherited from MY_Model

__call(), _get_from_cache(), _get_joined(), _get_table_fields(), _prep_after_read(), _prep_after_write(), _prep_before_read(), _prep_before_write(), _write_to_cache(), as_array(), as_dropdown(), as_object(), count_rows(), delete(), delete_cache(), fields(), fillable_fields(), force_delete(), from_form(), get(), get_all(), group_by(), insert(), is_assoc(), is_multidimensional(), join_temporary_results(), limit(), object_to_array(), on(), only_trashed(), order_by(), paginate(), reset_connection(), restore(), set_cache(), set_pagination_arrows(), set_pagination_delimiters(), trashed(), trigger(), update(), where(), with(), with_trashed(), without_trashed()

Properties summary

public null $table

Sets table name

Sets table name

# 'articles'
public null $primary_key

Sets PRIMARY KEY

Sets PRIMARY KEY

# 'id'
public array $protected

Sets protected fields

Sets protected fields

# array('id')
public string $return_as
# 'array'
public $rules
#

Properties inherited from MY_Model

$_cache, $_created_at_field, $_database, $_database_connection, $_deleted_at_field, $_dropdown_field, $_updated_at_field, $after_create, $after_delete, $after_get, $after_soft_delete, $after_update, $all_pages, $before_create, $before_delete, $before_get, $before_soft_delete, $before_update, $cache_driver, $cache_prefix, $callback_parameters, $delete_cache_on_save, $fillable, $has_many, $has_many_pivot, $has_one, $next_page, $pagination_arrows, $pagination_delimiters, $previous_page, $return_as_dropdown, $separate_subqueries, $soft_deletes, $table_fields, $timestamps, $timestamps_format

CAFPE Docs API documentation generated by ApiGen