X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=NOTES.txt;h=115251c59a561381f880a6e5d7c6731712300f3a;hb=bf3e7004c6eff0bf24562c30492df38005b48cfb;hp=8bf578f9f4455e16c611b5582b8b22d92d57a1fc;hpb=14d2a1faa534d15220b1e04386d4471127cd7cee;p=dbsrgits%2FDBIx-Class-Manual-SQLHackers.git diff --git a/NOTES.txt b/NOTES.txt index 8bf578f..115251c 100644 --- a/NOTES.txt +++ b/NOTES.txt @@ -1,41 +1,5 @@ ## Removed from UPDATE.pod: -=head2 Update a row or rows using a column calculation - - -- Yet another pointless example - UPDATE users - SET username = username || '.uk' - WHERE id = 1; - -=over - -=item 1. Create a Schema object representing the database you are working with: - - my $schema = MyDatabase::Schema->connect('dbi:SQLite:my.db'); - -=item 2. Call the B method on the resultset for the L you wish to fetch data from: - - my $fred_user = $schema->resultset('User')->find({ id => 1 }); - -The Row object has an B method that will change the values on -the object, and send an UPDATE query to the database. - -=item 3. Call the B method, passing it a hashref of new data: - -# this won't yet work, DBIC for now mandates the [ {} => $value ] format, the simple \[ $sql, $value1, $value2 ] will start being recognized later on -# the only documentation we currently have is this, if you can turn it into a DBIC pod-patch it will be freaking awesome -# 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. - - -=back - =head2 Update a row based on data in other tables -- Slightly less pointless example