可以在PHP中将字符串转换为varbinary,而不使用SQL函数 [英] is it possible to convert a string to varbinary in PHP without using the SQL function

查看:126
本文介绍了可以在PHP中将字符串转换为varbinary,而不使用SQL函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以使用PHP将字符串转换为varbinary,以获得与使用SQL函数相同的效果 CONVERT(varbinary,'data')我想这样做,因为我使用codeigniter,并希望使用活动记录此查询,并且因为这不直接使用一个字符串的SQL,但我需要插入数据到MS-SQL中的varbinary字段。

I was wondering if it is possible to convert a string to varbinary with PHP to get the same effect as with using the SQL function CONVERT(varbinary, 'data') I would like to do this because I am using codeigniter and would like to use active records for this query, and because of this not directly use a string of SQL, but I need to insert the data into a varbinary field in MS-SQL.

感谢:)

推荐答案

$binary = (binary)$string;

(二进制)转换和b前缀转发支持在PHP 5.2.1中添加

(binary) casting and b prefix forward support was added in PHP 5.2.1

http://www.php.net/ manual / en / language.types.type-juggling.php

这篇关于可以在PHP中将字符串转换为varbinary,而不使用SQL函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆