MySQL++ query question

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2007
Posts: 35
Reputation: Tales is an unknown quantity at this point 
Solved Threads: 1
Tales Tales is online now Online
Light Poster

MySQL++ query question

 
0
  #1
Apr 3rd, 2007
I want to make a query in C++ using the MySQL++ API.

Here is my problem, in PHP for example I make something like this:

$query = "SELECT * FROM table1 WHERE id = " . $value;

In C++ I can't do that. I need a way to make $value be part of the query string. I know it is a silly question, but can someone help me find this answer?

Thank You
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,334
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1454
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: MySQL++ query question

 
0
  #2
Apr 3rd, 2007
you could use std::string class and just concantinate the value with the string
  1. std::string query = "SELECT * FROM table1 WHERE id = ";
  2. query += value;

now the problem is that if value is a string you will probably have to enclose it in quotes

  1. std::string query = "SELECT * FROM table1 WHERE id = '";
  2. query += value;
  3. query += "'";
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC