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 8929965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:47:00+00:00 2026-06-15T08:47:00+00:00

When I am saving data having two enum fields to manage to manage status

  • 0

When I am saving data having two enum fields to manage to manage status of message i.e. read or unread by user. I am using enum (‘1′,’0’) to manage status ‘1’ => read and ‘0’=> unread

following code will save the message but in status column saving empty filed

$data = array(
              'message' => 'test message',
              'status' => 1
             );

$this->Message->save($data);

database structure is as follow

Field                Type                  Collation          Null    Key     Default 
------------------  -------------        -----------------  ------  ------  -------  
id                   bigint(20)            (NULL)             NO      PRI     (NULL)   
message              varchar(255)          (NULL)             NO      MUL     (NULL)                                                         
status               enum('0','1')         latin1_swedish_ci  NO      MUL     0 

even I have used data array as

$data = array(
              'message' => 'test message',
              'status' => '1'
             );


$data = array(
              'message' => 'test message',
              'status' => "'".1."'"
             );
  • 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-15T08:47:01+00:00Added an answer on June 15, 2026 at 8:47 am

    you are using cakephp – it does (as documented) not support ENUM.
    and in your case it is wrong to even use enums in the first place. Enums are used for more than two states and should be emulated as ArrayDatasource or in your model (as I do).

    But “read/unread” is a boolean (two definite states!).

    and there is an easy way to accomplish this correctly:

    tinyint(1) [unsigned] [default 0]
    

    cake will automatically assume this is a boolean and will transform the form field for it into a checkbox.

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

Sidebar

Related Questions

I am having trouble saving a photo into core data. I am trying to
I am having problems while saving a pre-persisted JDO object in google-app-engine data store.
Every thing goes in code, but not saving data in SQLite db. Can any
I am studying Data Structures in java and I am having difficulty with using
Having a problem getting some data persisted with hibernate I declare two independent classes,
I'm having a little bit of trouble saving data to a database. Basically, I
Having a hard time saving data from a native text field to sqlite database
I'm saving data to a table, but I also need a column with a
I am working on a project in which I am saving data in a
So, there have been several posts here about importing and saving data from an

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.