Welcome Guest, Not a member yet? Register   Sign In
DMZ Problem
#14

[eluser]WanWizard[/eluser]
Sorry, didn't notice that you were trying to get from page to portal, that should indeed work without the FK.

Ran a test using a fresh CI installation, copied the Datamapper library and the helpers in, created a test database with your tables, and created the models just are you posted them.
I've added this method to Welcome.php:
Code:
function test()
{
    $this->load->database();

    $page = new Page();
    $portal = new Portal();
    $category = new Category();

    var_dump($category->get_where(array('portal_id'=>'2'))->to_array());
    var_dump($category->portal->get()->to_array());

    var_dump($page->get_where(array('portal_id'=>'2'))->to_array());
    var_dump($page->portal->get()->to_array());
}

Calling this method produces:

Code:
array
  'id' => int 6
  'portal_id' => string '2' (length=1)
  'title' => string 'My Category' (length=11)
  'description' => string 'cat desc' (length=8)
  'slug' => string '/slug/cat' (length=9)
  'created' => string '2010-08-01 11:25:09' (length=19)
  'updated' => string '2010-08-01 11:25:09' (length=19)

array
  'id' => int 2
  'title' => string 'My Portal' (length=9)
  'created' => string '2010-08-01 11:25:09' (length=19)
  'updated' => string '2010-08-01 11:25:09' (length=19)
  'slug' => string '/slug' (length=5)

array
  'id' => int 6
  'portal_id' => string '2' (length=1)
  'title' => string 'My Page' (length=7)
  'content' => string 'Content here' (length=12)
  'slug' => string '/slug/page' (length=10)
  'created' => string '2010-08-01 11:25:09' (length=19)
  'updated' => string '2010-08-01 11:25:09' (length=19)

array
  'id' => int 2
  'title' => string 'My Portal' (length=9)
  'created' => string '2010-08-01 11:25:09' (length=19)
  'updated' => string '2010-08-01 11:25:09' (length=19)
  'slug' => string '/slug' (length=5)

Conclusion: works as advertised. So your error is elsewhere.

You're not having a library or a controller called 'page' do you, which causes $this->page to exist, and the model not to be loaded.


Messages In This Thread
DMZ Problem - by El Forum - 08-19-2010, 05:23 PM
DMZ Problem - by El Forum - 08-19-2010, 06:37 PM
DMZ Problem - by El Forum - 08-19-2010, 06:55 PM
DMZ Problem - by El Forum - 08-19-2010, 07:08 PM
DMZ Problem - by El Forum - 08-19-2010, 07:35 PM
DMZ Problem - by El Forum - 08-19-2010, 07:41 PM
DMZ Problem - by El Forum - 08-19-2010, 07:43 PM
DMZ Problem - by El Forum - 08-19-2010, 07:43 PM
DMZ Problem - by El Forum - 08-19-2010, 07:45 PM
DMZ Problem - by El Forum - 08-20-2010, 12:01 AM
DMZ Problem - by El Forum - 08-20-2010, 01:28 AM
DMZ Problem - by El Forum - 08-20-2010, 02:36 AM
DMZ Problem - by El Forum - 08-20-2010, 02:40 AM
DMZ Problem - by El Forum - 08-20-2010, 03:35 AM
DMZ Problem - by El Forum - 08-20-2010, 12:32 PM
DMZ Problem - by El Forum - 08-20-2010, 01:53 PM
DMZ Problem - by El Forum - 08-20-2010, 03:11 PM
DMZ Problem - by El Forum - 08-23-2010, 07:15 PM
DMZ Problem - by El Forum - 08-24-2010, 12:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB