logo
Автор: n0xi0uzz
Описание: MySQL++ example
Язык: C++
#include <iostream>
#include <mysql++.h>
using namespace std;
using namespace mysqlpp;

int main() {
	try {
		char db[] = "testdb";
		char host[] = "localhost";
		char user[] = "testuser";
		char passwd[] = "secret";
		Connection c(db, host, user, passwd);
		if(c) cout << "==> Connected" << endl;
		
		Query q = c.query();
		q << "SELECT * FROM testtable";
		Result r = q.store();
	
		if(r.num_rows() > 0) {
			Row row;
			for(int i = 0; i < r.num_rows(), row = r.at(i); i++) {
				cout << "=>" << row["column1"] << row["column2"] << endl;
			}
		} else {
			cout << "=> No results returned.";
		}
	} catch (Exception& e) {
		cout << "==> Error: " << e.what() << endl;
	}
}
Последние размещения:
blessmaster (PHP)
antonivanov (SQL)
antonivanov (PHP)
brinza (PHP)
ilyhamas (Delphi)
Riateche (PHP)
otherlight (Java)
otherlight (JavaScript)
otherlight (CSS)
otherlight (CSS)
biophreak (JavaScript)
n4n (Perl)
prostoHz (Java)
ndubinkin (XML)
Riateche (Plain Text)
Slapotam (Perl)
ksurent (Perl)
John_Wein (Java)
John_Wein (HTML)
Riateche (HTML)
netsago.paste.β © 2009 Neunica