Might be worth logging a CakePHP issue/ticket on lighthouse.
https://cakephp.lighthouseapp.com/projects/42648-cakephp/overview
On Wed, Aug 14, 2013 at 1:43 AM, Roosevelt P <rooseveltrp@yahoo.com> wrote:
> Hi,
>
> I generated a Schema file. And the schema file creates records for two
> tables under the function after(). If I run the create command on the
> default
> table it works just fine. But if I specify the --connection argument 'test',
> it creates the tables under 'test' just fine but tries to insert the records
> to the default
> connection regardless of the --connection parameter.
>
> // Works fine. Creates the tables under the default database and inserts
> records
> $ Console/cake schema create -s 1
>
> // Breaks. Creates the tables under 'test' connection but tries to insert
> the record under the 'default' database connection
> $ Console/cake schema create -s 1 --connection test
>
> I believe it might has something to do with the after() method or it could
> be a bug within CakePHP console.
>
> Here is the partial code of my Schema file:
>
> <?php
>
> App::uses("ClassRegistry", "Utility");
> App::uses("Shoe", 'Model');
>
> class AppSchema extends CakeSchema {
>
> public function before($event = array()) {
> debug($this->connection); // always prints default :/
> $db = ConnectionManager::getDataSource($this->connection);
> $db->cacheSources = false;
> return true;
> }
>
> public function after($event = array()) {
> if(isset($event['create'])){
> switch($event['create']){
> case "shoes":
> $this->InsertDefaultShoes();
> break;
> }
> }
> }
>
> public function InsertDefaultShoes(){
> $shoe = ClassRegistry::init("Shoe");
> $records = array(
> array(
> "Shoe" => array(
> "name" => "Shoe 1"
> )
> ),
> array(
> "Shoe" => array(
> "name" => "Shoe 1",
> )
> )
> );
> $shoe->saveAll($records);
> }
>
> ......
>
> }
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscribe@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
Simon Males
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
Wednesday, August 14, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment