mysql-native: API Refresh RC

Nick Sabalausky via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Wed Feb 1 20:04:15 PST 2017


On 02/01/2017 01:54 PM, Suliman wrote:
> Also I can't understand what is SQL Command and what exec is doing if
> it's returning ulong?
>
>

"struct Command" should not be used. It is old, and a bad design. This 
new release attempts to replace it with a better design. Hopefully, 
"struct Command" will be deleted in a later release.

The "exec" functions are for commands like INSERT, UPDATE, DELETE, 
CREATE, etc (it is *not* for SELECT). It is for things that do NOT 
return actual rows of data. The "exec" functions return "rows affected" 
- the number of rows that were affected by your INSERT, or UPDATE, etc. 
Usually people ignore that number, but it's information the server sends 
back, and is sometimes useful to some people. For example, SQL 
administration tools usually tell you "# rows affected" after you run an 
INSERT/UPDATE/etc.

If you are doing a SELECT, then you do NOT use "exec", you use "query" 
for SELECT. "query" returns a set of rows.

Summary:
---------

SELECT: Use query() or querySet() or queryRow(), etc.

INSERT/UPDATE/DELETE/CREATE/DROP: Use exec(). Return value tells you how 
many rows were added/changed/deleted/etc.



More information about the Digitalmars-d-announce mailing list