Batch insert Code Yii: $ app-& amp; gt; db-& amp; gt; createCommand ()-& amp; gt; batchInsert ($ rangeDetailModel: tableName (), [& #039; type & #039;, & #039; range_id & #039;, & #039; value & #039;], $ branchArr)-& amp; gt; execute (); to add the following behavior publicfunctionbehaviors (){... batch insert Code
Yii: $ app-> db-> createCommand ()-> batchInsert ($ rangeDetailModel: tableName (), ['type', 'range _ id ', 'value'], $ branchArr)-> execute ();
To add the following actions
Public function behaviors ()
{Return [['class' => BlameableBehavior: className (), 'bubuckets' => [ActiveRecord: EVENT_BEFORE_INSERT => ['create _ by'], ActiveRecord :: EVENT_BEFORE_UPDATE => 'lastupdate _ by'], 'timestamp' => ['class' => 'yii \ behaviors \ TimestampBehavior ', 'bubuckets' => [ActiveRecord :: EVENT_BEFORE_INSERT => ['create _ dt ', 'lastupdate _ dt'], ActiveRecord: EVENT_BEFORE_UPDATE => ['lastupdate _ dt '];} this behavior is used by default in AR, but it won't work if I use BATCHINSERT. I tried to write it like this. Although there is nothing soft to use $ beh ['yii \ behaviors \ BlameableBehavior '] = [ActiveRecord:: EVENT_BEFORE_INSERT => ['create _ by'], ActiveRecord: EVENT_BEFORE_UPDATE => 'lastupdate _ by']; Yii: $ app-> db-> createCommand () -> batchInsert ($ rangeDetailModel: tableName (), ['type', 'range _ id', 'value'], $ are1_r)-> attachBehaviors ($ beh) -> execute ();
Reply content:
Batch insert Code
Yii: $ app-> db-> createCommand ()-> batchInsert ($ rangeDetailModel: tableName (), ['type', 'range _ id ', 'value'], $ branchArr)-> execute ();
To add the following actions
Public function behaviors ()
{Return [['class' => BlameableBehavior: className (), 'bubuckets' => [ActiveRecord: EVENT_BEFORE_INSERT => ['create _ by'], ActiveRecord :: EVENT_BEFORE_UPDATE => 'lastupdate _ by'], 'timestamp' => ['class' => 'yii \ behaviors \ TimestampBehavior ', 'bubuckets' => [ActiveRecord :: EVENT_BEFORE_INSERT => ['create _ dt ', 'lastupdate _ dt'], ActiveRecord: EVENT_BEFORE_UPDATE => ['lastupdate _ dt '];} this behavior is used by default in AR, but it won't work if I use BATCHINSERT. I tried to write it like this. Although there is nothing soft to use $ beh ['yii \ behaviors \ BlameableBehavior '] = [ActiveRecord:: EVENT_BEFORE_INSERT => ['create _ by'], ActiveRecord: EVENT_BEFORE_UPDATE => 'lastupdate _ by']; Yii: $ app-> db-> createCommand () -> batchInsert ($ rangeDetailModel: tableName (), ['type', 'range _ id', 'value'], $ are1_r)-> attachBehaviors ($ beh) -> execute ();
createCommandIt is dao, and it is out of ActiveRecord.
You can simply set the time for your ar.