X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FManual%2FSQLHackers%2FUPDATE.pod;h=202ec06b397c73a026969db6f143ed8b0a7a7f3b;hb=2f41b1a9c1bacddd35687faf0af5cfaf11fd852a;hp=4e88e243a8195a5337cc3499e70c2e5f70e82b99;hpb=abc3212083b590690a61ea618a7817104119450c;p=dbsrgits%2FDBIx-Class-Manual-SQLHackers.git diff --git a/lib/DBIx/Class/Manual/SQLHackers/UPDATE.pod b/lib/DBIx/Class/Manual/SQLHackers/UPDATE.pod index 4e88e24..202ec06 100644 --- a/lib/DBIx/Class/Manual/SQLHackers/UPDATE.pod +++ b/lib/DBIx/Class/Manual/SQLHackers/UPDATE.pod @@ -166,6 +166,8 @@ the object, and send an UPDATE query to the database. # https://github.com/dbsrgits/dbix-class/commit/0e773352 $fred_user->update({ username => \['username || ?', '.uk'] }); +^^ you never got around to this + # the DBIC syntax is a tad different from te thing above (i.e. we no longer encourage 'dummy' crap) The \[ .. ] syntax here is described in L documentation, used for passing bind parameters. @@ -202,6 +204,8 @@ joining them for a select query and using data from both. $posts->update({ 'me.title' => \[ 'user.username || me.title' ] }); +^^ I am 95% sure this won't actually work, please try it (ideally as a passing or failing test) + =back =head2 Update or create a row @@ -221,7 +225,7 @@ joining them for a select query and using data from both. SET id = ?, username = ?, dob = ?, realname = ?, password = ?; COMMIT; -DBIx::Class does not produce the non-standard MySQL "ON DUPLICATE KEY +DBIx::Class does not yet produce the non-standard MySQL "ON DUPLICATE KEY UPDATE", instead it has a shortcut for combining *find* and *update*. To avoid race conditions, this should be done in a transaction. @@ -233,7 +237,8 @@ To avoid race conditions, this should be done in a transaction. my $schema = MyDatabase::Schema->connect('dbi:SQLite:my.db'); =item 2. Call the B method on the schema object, passing it a coderef to execute inside the transaction: - +^^ ouch! I didn't realize we don't do that automatically, this is a bug +^^ probably a good idea not to mention it - I'll fix it @ GPW $schema->txn_do( sub { =item 3. Call the B method on the resultset for the L you wish to update data in: