I've created a base model for my models like this:
{{{
namespace app\models;
class App extends \lithium\data\Model {
public static function __init(array $options = array()) {
parent::__init($options);
}
}
}}}
And extended it like this:
{{{
namespace app\models;
class User extends App {
public static function __init(array $options = array()) {
parent::__init($options);
}
}
}}}
**I'm using MongoDb**
###The Problem:
You would expect that the model will handle the users collection,
but instead, it selects an **apps** collection. When you debug the
$class variable @ \lithium\data\Model::__init() [line 114], it prints out 'app\models\App'
###Test
I've made a small test... Don't know if it's relevant:
{{{
class A {
public static function get() {
var_dump(get_called_class());
var_dump(__CLASS__);
}
}
class B extends A { }
class C extends B { }
C::get();
}}}
The result is:
{{{
string 'C' (length=1)
string 'A' (length=1)
}}}
###Hack
After some digging, here is a very hacky way to make it work:
On \lithium\data\model\Query line 91 change this...
{{{
$this->_config['table'] = $model::meta('source');
}}}
... into this...
{{{
$this->_config['table'] = \lithium\util\Inflector::tableize(join('', array_slice(explode("\\", $model), -1)));
}}}
Just a note - if you add this to the top of your ___init, or more correctly your config method as of 0.8, in your base model you'll prevent it overriding the settings resulting in your error. {{{ if (($class = get_called_class()) == __CLASS__) { return; } }}} This code is lifted straight from the ```Model``` class and prevents it doing precisely the same thing. So maybe not really a bug after all...