C++DB is the database layer that was designed to work with C++CMS. This customized version is used within Ye Ol' Pi Shack.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

54 lines
1.8 KiB

  1. //-----------------------------------------------------------
  2. /*! \page intro Quick Start Guide
  3. \section codesmaple The Code
  4. The best is to start from this example
  5. \include example1.cpp
  6. First we connect to the database using \ref connstr "cppdb connection string". Then
  7. we execute a simple sql query.
  8. When you write
  9. \code
  10. sql << "DROP TABLE IF EXISTS test" << cppdb::exec;
  11. \endcode
  12. \section codedesc Description
  13. You actually first prepare a statement (using first operator "<<") and then execute it using a cppdb::exec manipulator.
  14. In the same way we create the table we need.
  15. Then we create a statement that we will use multiple times. At first we prepare a statement using
  16. operator "<<" and then we bind parameters to it. Note, the string is passed as is without escaping
  17. it in any way. Then we execute a statement calling stat.exec(). Note it could be done using
  18. manipulator as well in previous line, but this is just a more verbose way and probably more clean way
  19. to do it.
  20. Then calling stat.last_insert_id() and stat.affected() we fetch the data about last executed statement.
  21. We can use our statement again after calling cppdb::statement::reset() function. In the next
  22. statement execution we would use more "verbose" variant of binding parameters - using bind()
  23. functions of statement, and then executing it.
  24. Then fetch the results we created. We prepare a query and assign it into \a res variable
  25. efficiently fetching the query result.
  26. Then we iterate over result's rows using res.next(), for each row we fetch the data using
  27. operator ">>".
  28. In the next query we select several values into a single row. We prepare a statement,
  29. bind a key 1 for the placeholder "?" and then we check if the row was actually fetched
  30. and we fetch values. We can fetch values using operator ">>" as above, however we can
  31. also fetch them using column names or indexes.
  32. */