Yii Framework Forum: Inserting unicode chars via yii1.1.17/pdo_dblib/freetds into SQL Server - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Inserting unicode chars via yii1.1.17/pdo_dblib/freetds into SQL Server Rate Topic: -----

#1 User is offline   somek1d 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 12-September 17

Posted 12 September 2017 - 01:52 PM

I'm trying to investigate the interaction via Yii 1.1.17, pdo_dblib, freetds, and SQL Server via a simple instantiation of the model. After setting utf8 as the charset in my database connection string and freetds, I've created the following action:

public function actionTest()
    {

        $db= Variable::model()->findByPk(1);
        echo "Before update: " . $db->Name . "<br>";

        $db->Name = '最';
        $db->update();
        echo "After update: " . $db->Name . "<br>";

    }



From the /tmp/freetds.log, I note the following query sent to SQL Server:

UPDATE [dbo].[Variable] SET [Name]='最' WHERE [dbo].[Variable].[VariableID]=1


Which results in a Name record of "?" in SQL Server, due to the lack of an N prefix: e.g. N'最'

Is this the intended behavior between these mechanisms? If not, have I misconfigured something along the way and if so, 1) does the limitation lie in Yii, Freetds, or SQL Server? and 2) are there any workarounds to support integration with SQL Server and Unicode via the model in Yii 1.1.x?

Note that the following examples work just fine, e.g. :

$db->Name = 'Hallå'

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users