tests/CommandTest.php
/**
     * Test whether param binding works in other places than WHERE.
     *
     * @dataProvider bindParamsNonWhereProviderTrait
     *
     * @param string $sql
     *
     * @throws Exception
     * @throws InvalidArgumentException
     * @throws InvalidConfigException
     * @throws NotSupportedException
     */
Test whether param binding works in other places than WHERE.

@param string $sql


Test whether param binding works in other places than WHERE . @param string $sql
public function testBindParamsNonWhere(string $sql): void
    {
        $db = $this->getConnection();
        $db->createCommand()->insert(
            'customer',
            [
                'name' => 'testParams',
                'email' => 'testParams@example.com',
                'address' => '1',
            ]
        )->execute();
        $params = [':email' => 'testParams@example.com', ':len' => 5];
        $command = $db->createCommand($sql, $params);
        $this->assertEquals('Params', $command->queryScalar());
    }
public function testBindParamsNonWhere ( string $ sql ) : void { $ db = $ this -> getConnection ( ) ; $ db -> createCommand ( ) -> insert ( 'customer' , [ 'name' => 'testParams' , 'email' => 'testParams@example.com' , 'address' => '1' , ] ) -> execute ( ) ; $ params = [ ':email' => 'testParams@example.com' , ':len' => 5 ] ; $ command = $ db -> createCommand ( $ sql , $ params ) ; $ this -> assertEquals ( 'Params' , $ command -> queryScalar ( ) ) ; }
Test whether param binding works in other places than WHERE.
Test whether param binding works in other places than WHERE .