Jump to content

Check out our Community Blogs

djnos14's Content

There have been 1 items by djnos14 (Search limited from 29-October 19)

Sort by                Order  

#551590 PHP, MSSQL 200, ntext/nvarchar

Posted by djnos14 on 13 April 2010 - 07:44 AM in General Programming

Hi !

I put my comment too late I think but if my answer can ever help you and others...
I was in front of the same mater and i resolved it like this :

//retrieve a PDO handler instance
$dbHd=Tools_Data_PDOBridge::getInstance(Tools_Data_PDOBridge::PDO_MSSQL, 'server', 'db', 'user', 'pwd');
$dataToInsert=mb_convert_encoding($srcStr, 'UCS-2LE', 'UTF-8');
$arr = unpack('H*hex', $dataToInsert);


$hex = "0x{$arr['hex']}";
$str='insert into CIVILITE(CIV_LIBELLE, test) values(\''.mb_convert_encoding('éè$^^É', 'ISO-8859-1', 'UTF-8').'\', '.$hex.');';

echo $srcStr.PHP_EOL;

$st=$dbHd->query('select top 1 convert(varbinary(200), test) as test from CIVILITE where CIV_ID>3;');



$rtData=pack('H*', $civ['test']);
echo iconv('UCS-2LE', 'UTF-8', $rtData);

Bye! :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download