Author: wyoung
Date: Tue Apr 17 06:59:14 2007
New Revision: 1531
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1531&view=rev
Log:
Converted examples/cgi_jpeg.cpp to use SSQLS instead of raw row data.
Does NOT work right now. This is to test improvements to the library to
allow BLOBs in SSQLSes.
Modified:
trunk/examples/cgi_jpeg.cpp
Modified: trunk/examples/cgi_jpeg.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/cgi_jpeg.cpp?rev=1531&r1=1530&r2=1531&view=diff
==============================================================================
--- trunk/examples/cgi_jpeg.cpp (original)
+++ trunk/examples/cgi_jpeg.cpp Tue Apr 17 06:59:14 2007
@@ -28,6 +28,7 @@
***********************************************************************/
#include <mysql++.h>
+#include <custom.h>
using namespace std;
using namespace mysqlpp;
@@ -36,6 +37,11 @@
#define IMG_HOST "localhost"
#define IMG_USER "root"
#define IMG_PASSWORD "nunyabinness"
+
+sql_create_2(images,
+ 1, 2,
+ mysqlpp::sql_int_unsigned, id,
+ mysqlpp::sql_blob, data)
int
main(int argc, char *argv[])
@@ -73,14 +79,14 @@
try {
con.connect(IMG_DATABASE, IMG_HOST, IMG_USER, IMG_PASSWORD);
Query query = con.query();
- query << "SELECT data FROM images WHERE id = " << img_id;
- Row row;
- Result res = query.store();
- if (res && (res.num_rows() > 0) && (row = res.at(0))) {
- unsigned long length = row.at(0).size();
+ query << "SELECT * FROM images WHERE id = " << img_id;
+ ResUse res = query.use();
+ if (res) {
+ images img = res.fetch_row();
+ unsigned long length = img.data.size();
cout << "Content-type: image/jpeg" << endl;
cout << "Content-length: " << length << endl << endl;
- fwrite(row.at(0).data(), 1, length, stdout);
+ fwrite(img.data.data(), 1, length, stdout);
}
else {
cout << "Content-type: text/plain" << endl << endl;
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits