[odb-users] Re: About using odb in same program to connect to mysql/sqlite/pgsql at same time

Scott Zhang macromarship at gmail.com
Thu Sep 13 06:38:56 EDT 2012


for last question, looks it should work. I notice the query_column has a
mysql namespace. And the generate person-odb.hxx, it explicitly use
mysql::query_column which when parse will generate mysql::query.

On Thu, Sep 13, 2012 at 6:32 PM, Scott Zhang <macromarship at gmail.com> wrote:

> Hello.
>     I am reading code to try to add pagination to odb. For orderby and
> groupby etc, as they are trial in most case, so append sql string is
> acceptable. Because I am going to replace my 2 projects DB access (one
> mysql, another oracle) library with odb, so I think add pagination will
> worth that.
>
>     Well. odb in my view is a really complex and heavy used template
> design. I am not sure the benefit of this. If the template was used to
> improve the flexibly to support static compiling check etc, because of so
> many different data types. I do think we have easier design. If you could
> look at the C# subsonic's activerecord template, from a "ODB/Subsonice
> compiler" level, the generate code can itself be static typed so could need
> less or none template. Just subsonic can reverse generate class from
> database. odb can generate persistent class from transient class.
>
>    And from the code flow. Looks I only need to add a Take(int num_),
> Offset(int offset_), (maybe OrderBy(string, enum orderby?)  and more ), in
> the "query" class then we can support "pagination". Because
>   for the query to run:
> eg:
>   result r (db->query<person> (query::age > 30));
> although the first sight to convert "query::age>30" or even more complex
> expression into a where clause looks mysterious. But after reading code,
> query::age itself is a query_column, which can parse ">30" and return a
> query. Then by the override operators, query can parse the left expressions
> itself. Then the place for the Offset, Take(orderby, groupby ....) could be
> after all where clause processed. We just need to call on  query object like
>
>    result r(db->query<person>(
> (query::aget>30).orderby(query::aget::column(), DESC).offset(10).take(10)) )
>
> then we can get the 10 - 20 rows.
>
>     And another question, from the code, looks odb::query linked with its
> mysql implementation  so the query it returned will be a mysql query. But
> if we link with both mysql and oracle at same time, eg for an application
> need to use mysql and oracle at same time. Can odb::query work correctly?
>
>
> Thanks.
> Regards
> Scott
>
>
>


More information about the odb-users mailing list