943,994 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3324
  • C++ RSS
Apr 3rd, 2007
0

MySQL++ query question

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
Tales is offline Offline
37 posts
since Mar 2007
Apr 3rd, 2007
0

Re: MySQL++ query question

you could use std::string class and just concantinate the value with the string
C++ Syntax (Toggle Plain Text)
  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

C++ Syntax (Toggle Plain Text)
  1. std::string query = "SELECT * FROM table1 WHERE id = '";
  2. query += value;
  3. query += "'";
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Dev C++ --> URGENT PLZ
Next Thread in C++ Forum Timeline: User-Defined Function - setup right?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC