mbajur
mbajur

Reputation: 4484

"array_merge(): Argument #2 is not an array" when using ORM

I'm creating a simple CMS using kohana3 in which user can add project to category. Here are my models:

<?php
# Project.php
class Model_Project extends ORM
{
    protected $_belongs_to = array('category');
}

# Category.php
class Model_Category extends ORM
{
    protected $_has_many = array('projects');
}
?>

Now, when i'm trying to use this code:

<?php
$category = ORM::factory('category');
$projects = $category->where('slug', '=', $slug)->projects->find_all();
?>

I'm getting the following error (MODPATH\orm\classes\kohana\orm.php [ 315 ]):

ErrorException [ Warning ]: array_merge() [function.array-merge]: Argument #2 is not an array

http://pastebin.com/knQBhmN5

Have you any idea what am i doing wrong? Any help would be appreciated.

Upvotes: 1

Views: 4315

Answers (1)

matino
matino

Reputation: 17735

There are 2 issues with your code, below fixes:

1. protected $_belongs_to = array('category' => array());
2. protected $_has_many = array('projects' => array());

Upvotes: 2

Related Questions