[Solar-talk] _PostCreate _autoCreate ver0.25 ver0.26?
Antti Holvikari
anttih at gmail.com
Mon Feb 5 04:00:39 PST 2007
On 2/5/07, Jeff Surgeson <webdev at 3hex.com> wrote:
> Hi Guys
>
> What am I missing here, I cant seem to get Solar to auto create tables if they
> do not already exist like they used to (pre ver0.25) or get _prostCreate to
> insert some data.
>
> I am using the same way to as I always did to load a data model, instantiate
> it etc.
>
> class Bulldog_Model_Users extends Solar_Sql_Table {
>
> protected function _setup()
> {
> $this->_name = 'users';
> $this->_col['user_email'] = array(.......etc);
> $this->_col['user_pass'] = array(......etc );
> }
>
> protected function _postCreate()
> {
> $user = array(
> 'user_email' => 'webdev at 3hex.com',
> 'user_pass' => md5('securepassword'),
> );
> $this->save($user);
> return true;
> }
>
> }
>
> and in my app..
>
> class Bulldog_App extends Solar_Controller_Page {
>
> $protected $_users;
>
> protected function _setup()
> {
> if (! Solar::isRegistered('sql')) {
> Solar::register('sql', Solar::factory('Solar_Sql'));
> }
> if (! Solar::isRegistered('user')) {
> Solar::register('user', Solar::factory('Solar_User'));
> }
> $this->_users = Solar::factory('Bulldog_Model_Users');
> }
>
> This used to work prior to ver0.25 but no longer works, if "users" table does
> not exist it does not auto create it as it did and then run _PostCreate to
> insert a row.
> I know Paul spoke some time ago about allowing autoCreate() to be turned off
> which I think he has done now with the "create" config key however the
> default is true so it should auto create without any configuration, correct?
>
> What am I missing, sorry if it is obvious or has been spoken about on list or
> in change list but I cant seem to find anything and Antti seem to use it OK
> in Abovo and I think that is ver0.25 ;-)
Just a quick note without that much investigation; I believe it's
because the _connect() has not been called. Take a look at
Abovo_Sql_Table[1] where I have added a autoconnect config key to
always connect in __construct(). I'm not sure though if this is your
problem...
[1] http://abovo.googlecode.com/svn/trunk/Abovo/Sql/Table.php
--
Antti Holvikari <http://phphalo.com>
More information about the solar-talk
mailing list