createMultipleInsertCommand issue

I’m using the following code to attempt to mass compose a message (insert multiple records into the message table that comes with Yii by default). The following code throws no error, yet it doesn’t insert any records. I’ve tried it both with the loop below and then just by attempting to manually insert a single record. Neither works. What am I missing?

Attempt to insert multiples from loop:




try {

                	$attr = array();


                	foreach($msgUsers as $id) {

                    	$a = array(

                        	'message'=>$model->message,

                        	'title'=>$model->title,

                        	'from_user_id'=>Yii::app()->user->id,

                        	'to_user_id'=>$id,

                        	'timestamp'=>time(),

                        	'message_read'=>0,

                        	'answered'=>0

                    	);


                    	$attr[] = $a;

                	}


                	$builder = Yii::app()->db->schema->commandBuilder;

                	$command = $builder->createMultipleInsertCommand('message', $attr);


                	print_r($command->execute());

                	Yii::app()->end();

            	} catch (Exception $e) {

                	print_r($e->getMessage());

                	Yii::app()->end();

            	}



Attempt to insert a single record manually:




try {

                	$attr = array();


                	foreach($msgUsers as $id) {

                    	$a = array(

                        	'message'=>$model->message,

                        	'title'=>$model->title,

                        	'from_user_id'=>Yii::app()->user->id,

                        	'to_user_id'=>$id,

                        	'timestamp'=>time(),

                        	'message_read'=>0,

                        	'answered'=>0

                    	);


                    	$attr[] = $a;

                	}


                	$builder = Yii::app()->db->schema->commandBuilder;

                	$command = $builder->createMultipleInsertCommand('message', array('message'=>'sasdasds', 'title'=>'wdwd',

                    	'from_user_id'=>16, 'to_user_id'=>1007, 'timestamp'=>1455507414, 'message_read'=>0, 'answered'=>0));


                	print_r($command->execute());

                	Yii::app()->end();

            	} catch (Exception $e) {

                	print_r($e->getMessage());

                	Yii::app()->end();

            	}



http://www.yiiframework.com/doc/api/1.1/CDbCommandBuilder#composeMultipleInsertCommand-detail

All adding fields are checked for existence, make sure that they exist in the table.

Perhaps the schema of the database was cached and yii not yet seen the new fields.

Also check logs of generated queries




'log' => [

	'class' => 'CLogRouter',

	'routes' => [

		

		'class'   => 'CProfileLogRoute',

		'report' => 'summary',

		'enabled' => true,

	],

	[

		'class'   => 'CWebLogRoute',

		'levels'  => 'error, info, warning, trace',

		'filter' => [

			'class' => 'CLogFilter',

			'logVars' => ['_GET', '_POST']

		],

		'enabled' => true,

	]

],