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

  • Home
  • SEARCH
  • 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 8462383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:09:06+00:00 2026-06-10T14:09:06+00:00

In my model, let’s call it questions, I have active field (TINYINT). The idea

  • 0

In my model, let’s call it “questions”, I have “active” field (TINYINT). The idea is, that only one entry in that particular model can be active. So when I update one entry by checking “active” checkbox, this entry should turn into active, and the other one should turn into unactive (I mean that one which has been active before). Any idea what query should I use?

  • 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-10T14:09:08+00:00Added an answer on June 10, 2026 at 2:09 pm

    some kind of toggle behavior for example.
    this behavior you write makes the model $actsAs = array('Toggable', array('field'=>'active'));

    and in your afterSave hook you make an updateAll call to reset all active ones to inactive (except the current id of course)

    that would be the cleanest approach.
    of course, you can always make a quick-and-dirty one using the models hooks itself for this.

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

Sidebar

Related Questions

In a webapp, i have a data-model (let's call it Item). The data of
Let's say I have User model and Post model. Post model contains field user_id
Let's say I have some model objects that resemble this: public class FooModel {
I've got a tiny model (let's call it Node) that represents a tree-like structure.
Let's say I have a model that looks like this: public class Blog {
Let's assume I have a model called product. Let's assume that product has three
Let's suppose I have a Discussion model, and that a discussion can be tagged.
Let's suppose I have a model with only two fields: name and street name
Let's say I have this model named Product with a field named brand .
Let say I have one model for cars. Each car has attributes: color, size,

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.