[Dbix-class] How to

Hailin Hu i at h2l.name
Tue Jun 19 06:45:45 GMT 2012


where => { for => 'update' }
is supposed to work.

try to debug with DBIC_TRACE=1 and see what exactly the sql is.

On Tue, Jun 19, 2012 at 3:36 PM, Hardik Joshi <hardik.maven at gmail.com> wrote:
> Thanks Alex,
>
> I have tried 'SELECT...FOR UPDATE' with normal DBI module and its working
> well where as via DBIx::Class its not working as per requirement.
>
> So, I feel I might missing something in DBIx::Class. do you have any idea
> for that?
>
> Thanks,
>
> Hardik Joshi
>
> On Tue, Jun 19, 2012 at 10:40 AM, Alex Erzin <eaa-home at yandex.ru> wrote:
>>
>> Not sure about DBIx::Class, but according to SQL you not need transaction
>> like "transaction begin/commit", but need something like "select for
>> update".
>> Quote from Mysql manual:
>>
>> -------
>> SELECT ... FOR UPDATE locks the rows and any associated index entries
>> <...>
>> Other transactions are blocked from updating those rows, from doing SELECT
>> ... LOCK IN SHARE MODE, or from reading the data in certain transaction
>> isolation levels.
>> -------
>>
>>
>> 19.06.2012, 08:31, "Hardik Joshi" <hardik at mavenvista.com>:
>>
>> Hello,
>> I have am working on one real time auction application where user used to
>> enter new bid based on previous minimum bid value. There is possibility that
>> two user will get same minimum value for their next bid. So I would like to
>> restrict second user on select statement if already first user has fired
>> select statement and waiting for insert statement to complete.
>> So could any one can guide me how to deal with such condition in
>> DBIx::Class.  I have tried
>> eg.
>> $schema->storage->txn_begin();
>> my $res = $schema->resultset('Test')->search($filter,
>> {for=>'update'})->first();
>> $schema->resultset('Test')->create($params);
>> $schema->storage->txn_commit();
>> Thanks,
>> Hardik Joshi
>>
>> _______________________________________________
>> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
>> IRC: irc.perl.org#dbix-class
>> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
>> Searchable Archive:
>> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>>
>> --
>> eaa@
>>
>> _______________________________________________
>> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
>> IRC: irc.perl.org#dbix-class
>> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
>> Searchable Archive:
>> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk



More information about the DBIx-Class mailing list