Sql -> Any tuto ?

simendsjo simendsjo at gmail.com
Fri Oct 25 01:31:50 PDT 2013


On Friday, 25 October 2013 at 08:07:02 UTC, Gary Willoughby wrote:
> On Saturday, 10 August 2013 at 18:28:31 UTC, H. S. Teoh wrote:
>> In that case, it should be written like this:
>>
>> 	...
>> 	command.prepare();
>> 	scope(exit) command.releaseStatement();
>>
>> 	ulong rowsAffected;
>> 	foreach ...
>>
>> This is exactly the kind of situation scope guards are 
>> designed for. So
>> use them! :-)
>>
>>
>> T
>
> It's sometimes not that simple if you are within try/catch 
> blocks or re-using the command for other queries.

Just a side-note: In the current version, the parameter packet is 
rebuilt on each request, so some of the advantages of reusing the 
statement might be lost if you only rebind a couple of the 
parameters.
https://github.com/rejectedsoftware/mysql-native/blob/master/source/mysql/connection.d#L4169

In my rewrite, I'm modifying the packet in-place, so it might be 
more performant.
https://github.com/simendsjo/mysqln/blob/master/source/mysql/protocol/packets.d#L782


More information about the Digitalmars-d-learn mailing list