Member Avatar for RudyM

Hi all,

I'm using CodeIgniter with MSSQL and works ok for basic queries. But then I do the following:

Add a varbinary(max) column to my table (new_col)
Change the query in the model: $this->db->get_where('user_stats_backup',array('new_col' => "0xD9E6762DD1C8EAF6D61B3C6192FC408D4D6D5F1176D0C29169BC24E71C3F274AD27FCD5811B313D681F7E55EC02D73D499C95455B6B5BB503ACF574FBA8FFE85")

When I load the page, it doesn't seem to be returning anything. I created a basic PHP page (outside of CodeIgniter) to run a query for this same value, and all works ok, with the exception of NOT including double quotes.

Recommended Answers

All 2 Replies

Hi,

try to submit the WHERE condition as a string:

$where = "new_col = 0xD9E6762DD1C8EAF6D61B3C6192FC408D4D6D5F1176D0C29169BC24E71C3F274AD27FCD5811B313D681F7E55EC02D73D499C95455B6B5BB503ACF574FBA8FFE85";
$this->db->get_where("user_stats_backup", $where);
Member Avatar for RudyM

Thanks, cereal, but no. It seems to confuse it for an identifier and complains about the identifier being too long, quoting the string. So I tried the following:

$this->db->query("select * from user_stats_backup where new_col = " . $this->db->escape_str($id));

And that worked. Now I'm trying to use query bindings, but no luck:

$query = $this->db->query("select * from user_stats_backup where new_col = ?",array($id));

Simply no results returned.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.