public static function createMultipleDeleteCommand($table, $data, $templates=null)
    {
        if(is_null($templates))
        {
            $templates = [
                'rowDeleteStatement'=>'DELETE FROM {{tableName}} WHERE {{rowDeleteCondition}}',
                'columnValueGlue'=>',',
                'rowDeleteConditionExpression'=>'{{colName}}={{colValue}}',
                'rowDeleteConditionJoin'=>' AND ',
                'rowDeleteStatementGlue'=>';',
            ];
        }

        $rowDeleteStatementGlue = $templates['rowDeleteStatementGlue'];

        $tableSchema=self::db()->schema->getTableSchema($tableName=$table);

        if($tableSchema===null)
            throw new Exception(Yii::t('yii','Table "{table}" does not exist.',
                ['{table}'=>$tableName]));
        $tableName=self::db()->quoteTableName($tableSchema->name);
        $params=[];
        $quoteColumnNames=[];

        $columns=[];

        foreach($data as $rowData)
        {
            foreach($rowData as $columnName=>$columnValue)
            {
                if(!in_array($columnName,$columns,true))
                    if($tableSchema->getColumn($columnName)!==null)
                        $columns[]=$columnName;
            }
        }

        foreach($columns as $name)
            $quoteColumnNames[$name]=self::db()->schema->quoteColumnName($name);

        $rowDeleteStatements=[];

        foreach($data as $rowKey=>$rowData)
        {
            $rowDeleteCondition = '';
            foreach($rowData as $columnName=>$columnValue)
            {
                /** @var \yii\db\ColumnSchema $column */
                $column=$tableSchema->getColumn($columnName);
                $paramValuePlaceHolder=':'.$columnName.'_'.$rowKey;
                $params[$paramValuePlaceHolder]=$column->dbTypecast($columnValue);

                if($rowDeleteCondition != '')
                    $rowDeleteCondition = $rowDeleteCondition.$templates['rowDeleteConditionJoin'];
                $rowDeleteCondition = $rowDeleteCondition.strtr($templates['rowDeleteConditionExpression'], array(
                        '{{colName}}'=>$columnName,
                        '{{colValue}}'=>$paramValuePlaceHolder,
                    ));
            }

            $rowDeleteStatements[]=strtr($templates['rowDeleteStatement'],array(
                '{{tableName}}'=>$tableName,
                '{{rowDeleteCondition}}'=>$rowDeleteCondition,
            ));
        }

        $sql=implode($rowDeleteStatementGlue, $rowDeleteStatements);

        if(self::db()->driverName =='mysql')
        {
            $rowCountStatement = 'SELECT ROW_COUNT()';
        }
        elseif(self::db()->driverName =='mssql')
        {
            $rowCountStatement = 'SELECT @@ROWCOUNT';
        }

        if(isset($rowCountStatement))
            $sql = $sql.$rowDeleteStatementGlue.$rowCountStatement;

        //Must ensure Yii::$app->db->emulatePrepare is set to TRUE;
        $command=self::db()->createCommand($sql);

        foreach($params as $name=>$value)
            $command->bindValue($name,$value);

        return $command;
    }