It would also help if anyone can point me to any examples of loading data in the schema before and after methods. -AZ
On Oct 17, 8:38 pm, azeckoski <[email protected]> wrote: > I am using the schema shell stuff (cake schema) to generate tables in > the database but I would like to also preload the tables with some > data. I found a possible way to do it by getting the datasource but I > am not sure this is really ideal (and it seems to fail with "Call to a > member function getColumnType() on a non-object"). Sample code of this > method is below. > > Is there a more cake like way to do this (that will actually work)? > Thanks for any suggestions! > -AZ > > ... > function after($event = array()) { > if ( isset($event["create"]) && $event["create"] == 'roles' ) > { > $db = &ConnectionManager::getDataSource( $this->connection ); > > $fields = array('creator','title'); > $values = array('preloader','Sample'); > $db->create($event["create"], $fields, $values); > } > } > > var $groups = array( > 'id' => array('type' => 'integer', 'null' => false, 'default' > => > NULL, 'length' => 10, 'key' => 'primary'), > 'eid' => array('type' => 'string', 'null' => true, 'default' > => > NULL), > 'created' => array('type' => 'datetime', 'null' => false, > 'default' > => NULL), > 'modified' => array('type' => 'datetime', 'null' => false, > 'default' > => NULL), > 'creator' => array('type' => 'string', 'null' => false, > 'default' => > NULL), > 'type' => array('type' => 'string', 'null' => false, > 'default' => > NULL), > 'title' => array('type' => 'string', 'null' => false, > 'default' => > NULL), > 'hidden' => array('type' => 'boolean', 'null' => false, > 'default' => > 0), > 'indexes' => array( > 'PRIMARY' => array('column' => 'id', 'unique' => 1), > 'type' => array('column' => 'type', 'unique' => 0), > 'eid' => array('column' => 'eid', 'unique' => 0), > 'hidden' => array('column' => 'hidden', 'unique' => 0) > ) > ); > > var $roles = array( > 'id' => array('type' => 'integer', 'null' => false, 'default' > => > NULL, 'length' => 10, 'key' => 'primary'), > 'eid' => array('type' => 'string', 'null' => true, 'default' > => > NULL), > 'created' => array('type' => 'datetime', 'null' => false, > 'default' > => NULL), > 'modified' => array('type' => 'datetime', 'null' => false, > 'default' > => NULL), > 'creator' => array('type' => 'string', 'null' => false, > 'default' => > NULL), > 'title' => array('type' => 'string', 'null' => false, > 'default' => > NULL), > 'indexes' => array( > 'PRIMARY' => array('column' => 'id', 'unique' => 1) > ) > ); > ... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
