Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8381951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:48:47+00:00 2026-06-09T16:48:47+00:00

I am using DBIx::Class and I would like to only update one row in

  • 0

I am using DBIx::Class and I would like to only update one row in my table. Currently this is how I do it:

my $session = my_app->model("DB::Session")->find(1);    
$session->update({done_yn=>'y',end_time=>\'NOW()'});

It works, but the problem is that when it does find to find the row, it does this whole query:

SELECT me.id, me.project_id, me.user_id, me.start_time, me.end_time, me.notes, me.done_yn FROM sessions me WHERE ( me.id = ? ): '8'

Which seems a bit much when all I want to do is update a row. Is there anyway to update a row without having to pull the whole row out of the database first? Something like this is what I am looking for:

my_app->model("DB::Session")->update({done_yn=>'y',end_time=>\'NOW()'},{id=>$id});

Where $id is the WHERE id=? part of the query. Does anyone know how to do this? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:48:49+00:00Added an answer on June 9, 2026 at 4:48 pm

    You can run update on a restricted resultset which only matches this single row:

    my_app->model("DB::Session")->search_rs({ id=> 1 })->update({done_yn=>'y',end_time=>\'NOW()'});

    I suggest you use a DateTime->now object instead of literal SQL for updating the end_time column because it uses the apps servers date and time instead of the database servers and makes your schema more compatible with different RDBMSes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using DBIx::Class and I have a query like this: $groups = $c->model('DB::Project')->search(
I have a Moose class that i would like to store using Apache::Session::File. However,
I am using DBIx::Class and I would like to select rows based on what
I'm using DBIx::Class in a web context and I'd like to display the number
In DBIx::Class, when I generate a query using this syntax: ... 'Time(submitted_at)' => {
I am using DBIx::Class and I have got a ResultSet. I like to re-order
I am trying to create a model for Catalyst by using DBIx::Class::Schema::Loader. I want
Using Rails 3.2.0 with haml and sass: I Would like to link an external
Using Jenkins or Hudson I would like to create a pipeline of builds with
I've got a simple temporal table that looks like this: Table: item_approval item user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.