If Only I Knew That!

Webby things that could save you time

Archive for April, 2010

Quick and easy block commenting for testing

with 4 comments

To save time commenting and uncommenting during development we use a little trick with the comment block that allows us to add or remove a single character ‘\’ to comment/uncomment a block.

Uncommented

/* */
Block of code
/* */

Commented

/* *\/
Block of code
/* */

Quick and simple time saver

Written by daveganley

April 21st, 2010 at 4:25 pm

Posted in PHP

CI-1.7.2 to CI-2.0 Model compatibility tweak

without comments

Spotted this in Ben Edmunds Ion Auth model, great way of making your models CI-1.7.2+ compatible.

//  CI 2.0 Compatibility
if(!class_exists('CI_Model')) { class CI_Model extends Model {} }

class MY_Model extends CI_Model
{
}

UPDATED:
Another way

// Let's add support for both Codeigniter 1.7 and 2.0
// Thanks to Dan Horrigan (http://dhorrigan.com/).
if (CI_VERSION >= 2)
{
  require_once(BASEPATH . 'core/CI_Model' . EXT);
  
  // Create an empty class so that we can extend Model while providing support for both CI 1.7 and 2.0
  class Model extends CI_Model {}
}
else
{
  require_once(BASEPATH . 'libraries/Model' . EXT);
}

// Then extend the CI 1.7 Model as usual

Written by daveganley

April 13th, 2010 at 10:58 am

Posted in Codeigniter

Powered by CDN Rewrites