Using BondDB

The base part of bonddb is the ‘Object’ structure. This would typically contain an sql select query of some kind. Using this object you can then navigate rows by using the db_moveto(…) function. You can also set and get values of specific fields in the Object based upon what row you are on.

You normally don’t need to use SQL statements to get ‘Objects’, there is a host of functions already provided for creating objects based on commonly requested queries. An example of this would be db_loadall or db_loadobjectbyobject etc. Bonddb looks after the relationship information so you don’t have to specify the joins. Its a good idea to have all your constraints defined in your database.

Another useful feature of bonddb is been able to link objects together so one object can contain many sub objects which are automatically updated based on the parent. dbmapme.c provides a lot of this functionality. The overall logging system will also update all objects you have currently loaded if there contents changes to the database side. This is useful if you are doing a lot of requests at the same time and you dont want to have to manually refresh your recordsets everytime you do a write.

dbgather.c and associate functions can provide your application with information regarding the backend database like what fields exist in what tables, what constraints exist etc. If your writting a generic interface to postgresql these functions can prove most useful.

Finally, dbtest.c offers a great amount of example code. Its a great way to become familiar with the API.