PropelBundle icon indicating copy to clipboard operation
PropelBundle copied to clipboard

MSSQL - Driver does not support setting attributes (SQLSTATE[IM001])

Open kinekt4 opened this issue 10 years ago • 4 comments

When making a connection to a MS SQL Server from Symfony2:

$con = Propel::getConnection('default');

I get the following error:

SQLSTATE[IM001]: Driver does not support this function: driver does not support setting attributes 

This happens when trying to set the following:

// app/config/config.yml
propel:
    database:
        connections:
            default:
              ...
              attributes:
                  ATTR_EMULATE_PREPARES:  true

However, even when this is removed, the error still persists because the DependencyInjector adds in a default:

// Propel\PropelBundle\DependencyInjection\Configuration
->arrayNode('attributes')
  ->addDefaultsIfNotSet()
    ->children()
        ->booleanNode('ATTR_EMULATE_PREPARES')->defaultFalse()->end()
    ->end()
->end()

If I remove like so, it works:

->arrayNode('attributes')
  ->addDefaultsIfNotSet()
->end()

Question: I wonder if the adapter should be checked before adding the default attribute ('ATTR_EMULATE_PREPARES) ?

Stack Trace

in vendor/propel/propel/src/Propel/Runtime/Connection/PdoConnection.php at line 76  -

        $attribute = constant($attribute);
    }
    return parent::setAttribute($attribute, $value);
}

adapter: mssql driver: pdo_dblib framework: symfony2 propel version: 2.0.0-dev

kinekt4 avatar Jul 24 '15 04:07 kinekt4

You can overwrite the attributes, by setting an empty array (or any other list), as this is what you want.

propel:
    database:
        connections:
            default:
              ...
              attributes: []

havvg avatar Jul 24 '15 07:07 havvg

I believe I tried this already and the DependencyInjector detects that the array is empty and goes ahead and adds the children. Let me confirm.

kinekt4 avatar Jul 30 '15 01:07 kinekt4

Can confirm that setting an empty array does not help.

kinekt4 avatar Sep 17 '15 03:09 kinekt4

don't use set attribut use array in pdo from the begining

Ismgh avatar Jun 16 '19 17:06 Ismgh