Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 112 revisions

[h2]Database[/h2]

[i]Checking under the hood of queries, that kind of thing[/i]

[h3]How do I see the actual raw SQL query generated by CI's Active Record[/h3]

[b]Answer 1[/b] Turn on [url="http://codeigniter.com/user_guide/general/profiling.html"]profiling[/url] (part of the benchmarking class) - this will show the full detail of all the SQL queries for the page.

[b]Answer 2[/b] You can do this before your query: [code] $this->db->_compile_select(); [/code] .. and then this, once you've run the query: [code] $this->db->last_query(); [/code]

[h2]Design[/h2]

[i]Architecture of your application, what goes where, design patterns, that kind of thing[/i]

[h3]I keep repeating lumps of code - things like login-dialogs, stylesheets, headers, footers, or menus - is there some place I can define them just once?[/h3]

This is covered in the [url="http://codeigniter.com/wiki/Header_and_footer_and_menu_on_every_page/"]Different Approaches Guide[/url] part of this wiki.

It is also covered a bit below (many references into the forums) in the 'Nested Templates / Views within views (etc) question.

[h3]How do I embed views within views? Nested templates? Header, Main, Footer (Blocks) design? Partials? Page Fragments? Ruby on Rails style Yield functionality?[/h3]

Check out the [url="http://codeigniter.com/wiki/Header_and_footer_and_menu_on_every_page/"]Different Approaches Guide[/url] to this problem.

There are several other described ways to deal with this problem:

Version 1.6 (Released January 31, 2008) has support for multiple views. See the User Guide for more details. That change to the core makes some of these approaches "old school" (as it were). This forum thread covers some good ground: [url=http://codeigniter.com/forums/viewthread/87346/]http://codeigniter.com/forums/viewthread/87346/[/url]

First, basic information on views and the optional third 'return' parameter: [url=http://www.codeigniter.com/wiki/Displaying_Multiple_Views/]http://www.codeigniter.com/wiki/Displaying_Multiple_Views/[/url] and also, [url=http://codeigniter.com/user_guide/libraries/loader.html]The CI Loader class documentation page[/url]

Coolfactor's View Library is one solution to nesting views in a tidy way. [url]http://codeigniter.com/forums/viewthread/49910/[/url]

Gyorgy Fekete's View library similar to Coolfactor's with the differences spelled out in the thread. [url]http://codeigniter.com/forums/viewthread/62521/[/url]

Another place to get advice if you don't want to add a new library is Rick Ellis' original thread on the subject (Embedding Views within Views). [url]http://codeigniter.com/forums/viewthread/44916/[/url]

Also, teamhurting has implemented a Ruby On Rails style Yield approach that uses CI's hooks system: [url=http://codeigniter.com/forums/viewthread/57902/]Yield using hooks - http://codeigniter.com/forums/viewthread/57902/[/url]

Another similar approach using a basic class rather than a class as a hook: [url=http://codeigniter.com/wiki/layout_library/]http://codeigniter.com/wiki/layout_library/[/url]

A thread where esra lists a few threads on this topic: [url=http://codeigniter.com/forums/viewthread/57965/]http://codeigniter.com/forums/viewthread/57965/[/url]

A Rails-Style ActionView library and helper called Ocular has a [url=http://codeigniter.com/wiki/Ocular_Layout_Library/]wiki page here: http://codeigniter.com/wiki/Ocular_Layout_Library/[/url] and a thread here: [url=http://codeigniter.com/forums/viewthread/65050/]http://codeigniter.com/forums/viewthread/65050/[/url]

A thread for a View library (author tested with Matchbox) [url=http://codeigniter.com/forums/viewthread/67028/]http://codeigniter.com/forums/viewthread/67028/[/url]

[h2]Platform differences[/h2]

[i]Relocating from GNU/Linux to Windows, changing databases engines, that kind of thing[/i]

[h3]I've moved my code from my development server site to my production server and now it doesn't work[/h3]

There are several sub-categories to this problem, depending what you mean by 'doesn't work'[/h4]

We assume that you have done the following steps: [b]o[/b] used [b]phpinfo.php[/b] to determine if [b]mod_rewrite[/b] is actually running [b]o[/b] checked the contents of your [b].htaccess[/b] for a specific reference to your dev box

[h4]Subcategory - my index.php isn't being hidden anymore[/h4] If your .htaccess mod_rewrite is no longer working -- check that you have [b]AllowOverride All[/b] in your [b]host's[/b] config file for the public web directory of your website.

[h2]CodeIgniter and Ellis Labs and Expression Engine[/h2]

[i]Release schedules, contributions, that kind of thing[/i]

[h3]When is the next version of Code Igniter coming out? What can I expect from the next version of Code Igniter?[/h3]

Code Igniter is a product of EllisLab. New releases and new features in the framework are made available when it is possible to release them, and may always be a surprise: [url]http://codeigniter.com/forums/viewthread/53619/P15/#262381[/url]

[h3]I've got cool new code for CI. What is the process for getting it included in the official CI distribution?[/h3]

New code is welcome, but not all code can be included. To maximize the chances of your code making it into CI, test (PHP 4 and 5) and document the code. All decisions about incorporating it fall to EllisLab. Basically, if you want to satisfy your lust for abiding fame you have to make an effort to promulgate your code to as many CI developers as possible who put it through an informal 'vetting' process. As part of this process you should create a 'manual page' to help people learn.

[h2]Plain old frequently asked questions[/h2]

[i]Almost a 'misc' category, but categorically [b]not[/b] a dumping ground - these are simply uncategorised questions ... for things that aren't any obvious or particular kind of thing yet[/i]

[h3]How do I find the name of the current controller and/or method?[/h3]

There are standard PHP function that's good for this kind of thing, and you're encouraged to consult the PHP User Guide.

[b]get_class()[/b] will return the current class's name.

[b]get_class_methods()[/b] will return the full list of methods for a given class.

Alternatively, consult the [url="http://codeigniter.com/user_guide/libraries/uri.html"]URI Class[/url] in the user manual, paying particular attention to the [b]rsegment()[/b] function - as you may be happy with pulling segment(1) for your class, and segment(2) for your method.

Alternatively, you can query the CI Routing class directly, using these functions: [code] $this->Router->class; $this->Router->method; [/code]

[h3]Can I cache only certain parts of a page? [/h3]

A. This is related to the question above about nested templates and partials. Basically, CI cache library (1.5.4) only supports full page caching - it's all or nothing. There are several contributions that can help.

[url=http://codeigniter.com/forums/viewthread/56456/]The Sparks library[/url] is one approach. (NOTE: [url=http://codeigniter.com/forums/viewthread/56456/P20/]the Sparks object caching library is currently an orphan[/url] (as of 20070925) as the developer has moved on to Zend Framework - anyone want to step up and carry it on?)

In case you have questions to ask on the forum, please review this general information on caches. There are many levels of caching and they can be broken down into a few categories and approaches:

PHP code itself: php opcode of some kind

The following can be classed as session-specific or global caches depending on the approach: DB cache: db query, db object serialization HTML output cache: partial or full page caching

Browser cache is always (by definition) session-specific: Browser cache: using headers to control cache, JS and CSS architecture to optimize browser cache-ability

[h3]How do I call methods in one controller via another controller?[/h3]

[i]Often this question disguises a requirement for some shared methods - consult the earlier question on [b]View Partials[/b] and [b]Header/Footer/Menu common views[/b] first, and confirm your question isn't better answered there.[/i]

Modular Extensions (ME) aka the HMVC library allows you to do this. [url=http://codeigniter.com/wiki/Modular_Extensions_-_HMVC/]ME/HMVC[/url]You don't. See [url=http://codeigniter.com/forums/viewthread/55212/]http://codeigniter.com/forums/viewthread/55212/[/url] for more discussion.

Category:Help

Clone this wiki locally