Search Postgresql Archives

Yet another PostgreSQL C++ binding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear All,

I've written a C++ PostgreSQL interface library which I use in a couple of open-source applications, and I thought that I would mention it here in case it could be of use to anyone. Yes, I know there are already several such libraries, but I believe mine has a unique feature: queries are functors that use prepared statements. Here's an example:

  Database db("dbname=foo, username=blah");
Query<string,int> insert_thing(db,"insert into things(name,num) values ($1,$2)"); SingletonQuery<int, string> count_things(db,"select sum(num) from things where name=$1");

  Transaction t(db);
  insert_thing("table",1);
  insert_thing("chair",4);
  int n = count_things("bed");
  t.commit();

Note how the queries are declared using the $n placeholder syntax for parameters. Once the queries are declared the fact that they are queries can be almost forgotten - they can be used as functions.

I have written up some basic documentation here:

    http://svn.chezphil.org/libpbe/trunk/doc/Database

Do let me know if you find this useful.

Regards,

Phil.

(I encourage you to Cc: me in any replies.)






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux