Welcome Guest, Not a member yet? Register   Sign In
using libraries in models
#6

[eluser]gtech[/eluser]
yes I have tested loading a library in a model and it works, not a good example of echoing content in a model! but just to show it works.

controller (application/controllers/temp.php):
Code:
<?php
class Temp extends Controller {

  function Temp()
  {
    parent::Controller();
  }
  function index()
  {
    $this->load->model('tester');
    $this->tester->loadlib();
  }
}
?>
library (application/libraries/template.php):
Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
class Template {
    function dotemplate()
    {
      echo "library";
    }
}
?>
model (application/models/tester.php):
Code:
<?php

class Tester extends Model
{
  function Tester()
  {
    parent::Model();
  }

  function loadlib()
  {
    $this->load->library('template');
    $this->template->dotemplate();
  }
}
?>

to add to what the others have said have you actually loaded the library in the controller to see if it works?


Messages In This Thread
using libraries in models - by El Forum - 05-29-2008, 01:47 PM
using libraries in models - by El Forum - 05-29-2008, 01:52 PM
using libraries in models - by El Forum - 05-29-2008, 02:16 PM
using libraries in models - by El Forum - 05-29-2008, 07:02 PM
using libraries in models - by El Forum - 05-29-2008, 07:54 PM
using libraries in models - by El Forum - 05-29-2008, 08:08 PM
using libraries in models - by El Forum - 05-29-2008, 08:14 PM
using libraries in models - by El Forum - 05-30-2008, 11:18 AM
using libraries in models - by El Forum - 05-30-2008, 11:34 AM
using libraries in models - by El Forum - 06-02-2008, 07:42 AM
using libraries in models - by El Forum - 06-02-2008, 03:30 PM
using libraries in models - by El Forum - 06-02-2008, 10:35 PM
using libraries in models - by El Forum - 06-03-2008, 01:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB