PHP code example of dotzero / yii-insertupdate-behavior

1. Go to this page and download the library: Download dotzero/yii-insertupdate-behavior library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dotzero / yii-insertupdate-behavior example snippets


'aliases' => array(
    ...
    'vendor' => realpath(__DIR__ . '/../../vendor'),
),
'import' => array(
    ...
    'vendor.dotzero.yii-insertupdate-behavior.*',
),

$command = Yii::app()->db->createCommand();
$command->attachBehavior('InsertUpdateCommandBehavior', new InsertUpdateCommandBehavior);
$command->insertUpdate('tbl_user', array(
    'name'=>'Tester',
    'email'=>'[email protected]',
    'counter'=>'1'
), array(
    'name'=>'Tester',
    'email'=>'[email protected]'
));

$command = Yii::app()->db->createCommand();
$command->attachBehavior('InsertUpdateCommandBehavior', new InsertUpdateCommandBehavior);
$command->insertUpdate('tbl_user', array(
    'name'=>'Tester',
    'email'=>'[email protected]',
    'counter'=>'1'
), array(
    'name'=>'Tester',
    'email'=>'[email protected]'
    'counter'=>new CDbExpression('LAST_INSERT_ID(counter)');
));