php - Laravel PDO Settings? -


i return int integers database. @ moment values loaded strings. database mssql 2012 , use pdo driver (for v5.6).

trying set properties here (as shown here on fideloper.com, don't know if that's still possible):

   'sqlsrv' => [         'driver'   => 'sqlsrv',         'charset'  => 'utf8',         'prefix'   => '',          ......         'options'   => array(             pdo::attr_stringify_fetches => false,             pdo::attr_emulate_prepares => false,         ),     ], 

but getting error:

sqlstate[imssp]: given attribute supported on pdostatement object. 

how can set settings pdo driver return int integers , not strings.

this still not working:

 $pdo = db::connection()->getpdo();  $pdo->setattribute(pdo::attr_stringify_fetches, false);  $pdo->setattribute(pdo::attr_emulate_prepares, false);  .. orm query 

bringing same error.

maybe can me?

i believe issue related pdo driver used (thats installed php, not laravel configuration).

not quite you're looking potentially solve problems. since laravel 5 theres been casts feature on eloquent columns automatically cast pre-defined types. see http://laravel.com/docs/5.0/eloquent#attribute-casting

// eloquent model protected $casts = [     'int_column'   => 'int', ]; 

your int_column automatically cast int when model retrieved database


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -