It should probably be mysql_num_rows for the row count, should it?jj2007 wrote:mysql_num_fields for both rows and columns?
Mysql advice
Re: Mysql advice
Re: Mysql advice
While it is a very nice tutorial, plenty info and explanations etc. ...
Keep in mind it's age: author writes FB ver. 0.20.0 (which is 32bit only),
and all the Integer's used, will probably have to be converted to Long.
Remember: Int (in C) = Long (in FB) || Integer (in FB) = Long (in C)
Keep in mind it's age: author writes FB ver. 0.20.0 (which is 32bit only),
and all the Integer's used, will probably have to be converted to Long.
Remember: Int (in C) = Long (in FB) || Integer (in FB) = Long (in C)
Re: Mysql advice
I've fixed the description of the sample application here: https://www.freebasic-portal.de/code-be ... n-218.htmlcaseih wrote:https://dev.mysql.com/doc/refman/5.7/en ... ields.html
https://dev.mysql.com/doc/refman/5.7/en ... -rows.html
Yes, probably a typo.
and contacted the author of the tutorial.
Making the example 64-bit ready probably needs some more work; I'll maybe do that at a later time.
Re: Mysql advice
In them examples how would i handle no items found?
Re: Mysql advice
No special code needed for handling that. mysql_num_rows will return zero in that case. You can test for nrows > 0 like in the example. Just don't forget to call mysql_free_result when you don't need the result (whether empty or not) anymore (e.g. have copied it to your own data structures or saved in a file).Gablea wrote:In them examples how would i handle no items found?
Re: Mysql advice
@St_W
That could be where I am going wrong I assume that mysql_free_result is the same as in Vb.net where i do DbCon.close (to close the connection to
the database so I can access it again from within another part of the program)
If it ok with you guys can I post here my test code to see if I am doing it right?
That could be where I am going wrong I assume that mysql_free_result is the same as in Vb.net where i do DbCon.close (to close the connection to
the database so I can access it again from within another part of the program)
If it ok with you guys can I post here my test code to see if I am doing it right?
Re: Mysql advice
hm, not really. mysql_close would rather correspond to that. Freeing memory is not needed in .NET (or Java) as those languages do have a garbage collector.Gablea wrote:That could be where I am going wrong I assume that mysql_free_result is the same as in Vb.net where i do DbCon.close (to close the connection to the database so I can access it again from within another part of the program)
Re: Mysql advice
As soon as you are done with a result you should call the mysql_result_free on it. But you don't need to call it before you use the connection for another query. As long as the connection is open you can make queries to it. The result structure is created on your program's heap, which is why it needs to be freed. It's an independent entity you can work with, once it is created and filled with data. Hope that makes sense.
Re: Mysql advice
So it sort of makes a dataset that I work with
That makes more sense :)
That makes more sense :)
Re: Mysql advice
That's my understanding, though it's possible they are client-side representation of server objects, which means you need to keep the connection open while you work with the results. Either way, though, a new result object is created every time you make a query so things can overlap safely.
How you work with connections and what life cycle a connection has depends on how you've designed your program. I've seen some database programs that keep a connection open for the life of the program. Others open and close connections frequently (for every web request even). Some keep a cache of connections that they use.
How you work with connections and what life cycle a connection has depends on how you've designed your program. I've seen some database programs that keep a connection open for the life of the program. Others open and close connections frequently (for every web request even). Some keep a cache of connections that they use.