* Michael Widenius <[EMAIL PROTECTED]> [02/03/26 12:41]:

> Konstantin> class Cursor
> Konstantin> {
> Konstantin>    Cursor(MYSQL_RES *res):_res(res) {}
> Konstantin>    bool fetch() { return mysql_fetch_row(_res); }
> Konstantin>    Row row() { return Row(_res->current_row); }
> Konstantin>    ~Cursor() { 
> Konstantin>         while (!mysql_eof(_res) && mysql_fetch_row(_res))
> Konstantin>             ;
> Konstantin>         mysql_free_result(_res);
> Konstantin>    }
> Konstantin> };
> Konstantin> In this code snippet I have to problems. 
> Konstantin> First, that I can't simply return to user current row without 
> Konstantin> moving the cursor to next row: there is no C API function like 
> Konstantin> mysql_current_row(). 
> Konstantin> Nevertheless, MYSQL_RES always stores current row in member field 
> Konstantin> 'current_row', so I have to use this undocumented feature 
> Konstantin> (I can have my own current_row, but why should I?)

> I couple of comments about the above:
> 
> - The code above would be safer against the future if you in the class
>   cursor stored the value from mysql_fetch_row and returned this in your 'row'
>   function, instead of relying on mysql->current_row.

I've realised eventually that You have reasons not to provide access for
mysql_res->current_row, and I do store my own copy of current_row in Cursor.

> In the ~function, you don't have to call mysql_fetch_row().
> mysql_free_result() will do this for you.

But, according to MYSQL C API documentation, 8.4.2, 
(http://www.mysql.com/documentation/mysql/bychapter/manual_Clients.html#C_API_function_overview)
I have to do this:

"An advantage of mysql_use_result() is that (...)
(...)
Furthermore, you must retrieve all the rows even if you determine in
mid-retrieval that you've found the information you were looking for."

> Anyway, it would still be nice if you could send your questions to
> [EMAIL PROTECTED] instead of directly to me;  I do get +300 emails
> per day and I simple don't have time to answer all questions direct to
> me :(

Sorry && thank you. 

-- 
 WBW, Konstantin Osipov
                                             

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to