Re: eDBI is born, feedback wanted
- Posted by jeremy (admin) Oct 16, 2009
- 1888 views
- get mysql_num_rows working. (I need to know how big to make my wxgrid)
Hm. I can see where this would be useful but it has to be done in a cross-database manner. Some database servers will not report the number of rows returned by a result until you consume all the available data (MySQL for example, see: mysql_num_rows and mysql_store_result). The downside to this is that the entire result set is then in memory at one point in time, which many will not want.
I'll have to ponder how to best handle this. It would be easy to add a new element to the query to store the number of rows but the idea of reading all available query data first just to get the number of rows isn't too exciting. I wonder if it wouldn't be best (as this is the rare case not the norm) to read all the rows into a sequence in Euphoria then just doing a length() on the resulting sequence? You would wind up with the data in memory twice for a short period of time but you do that anyway when you use mysql_store_result so that mysql_num_rows will work.
- catch connection errors - I get a machine-level exception in edbi.e when I supply the wrong database password
- catch SQL errors. It brings down my whole application
Yes... The early stage of eDBI (most products?) means that error handling is not the best. Right now a lot of things are assumed to just work . This is obviously not good but at first I wanted to get the API working then go back and do the important stuff
- best work with fields of type date/datetime. (I'm not hardcoding field names in my application, so to get a date formated, I'll have to go and get metadata to see if there are date fields, and when populating the grid, I'll have to format the column as date/datetime in the row loop, which is inefficient and too much work)
I would probably just do something like:
edbi:query("SELECT abc, def, DATE_FORMAT(mydate, '%m/%d/%Y') AS mydate FROM xyz")
That is, if you do not want to do any date processing on it in Euphoria. That will return a string value.
Jeremy