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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:58:00+00:00 2026-05-25T15:58:00+00:00

EDIT I have modified my table so that my primary key is id, and

  • 0

EDIT

I have modified my table so that my primary key is id, and everything works correctly. Still trying to figure this issue out.

I have the model below that I am using to handle various eav values. The issue that I am seeing is that when I use $Model->save(), it will always try to insert and not update. Even if I set the property/value of the primaryKey.

Event when inserting, I have noticed that I get this query the query below in my logs. The primary key of the table is value_id.

SELECT COUNT(*) AS `count` FROM `user_entity_varchars` AS `UserEntityVarchar` 
    WHERE `UserEntityVarchar`.`id` = '1'

When I output the debug of the model’s structure, this is what I am seeing:

[useDbConfig] => default
[useTable] => user_entity_varchars
[displayField] => 
[id] => 
[data] => Array
    (
    )

[table] => user_entity_varchars
[primaryKey] => id

For some reason it is not recognizing that the primary key is set in the model class.

This is the model that I am using:

<?php
class UserEntityVarchar extends UserAgentAppModel {
var $name = 'UserEntityVarchar';
var $primaryKey = 'value_id';

var $belongsTo = array(
    'UserEntity'=>array(
    'foreignKey' => 'entity_id'
    ));
var $hasOne = array(
    'EavAttribute' => array(
    'foreignKey' => 'attribute_id'
    ));

}
?>
  • 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-05-25T15:58:00+00:00Added an answer on May 25, 2026 at 3:58 pm

    You are setting the primaryKey on the model as “value_id”, try changing this line to:

     <?php
    class UserEntityVarchar extends UserAgentAppModel {
    var $name = 'UserEntityVarchar';
    /*var $primaryKey = 'value_id'; Change this to*/
    var $primaryKey = 'id';
    
    var $belongsTo = array(
        'UserEntity'=>array(
        'foreignKey' => 'entity_id'
        ));
    var $hasOne = array(
        'EavAttribute' => array(
        'foreignKey' => 'attribute_id'
        ));
    
    }
    ?>
    

    Hope it helps!
    cheers

    pd, it is my first post!

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

Sidebar

Related Questions

I have the following table of counters: CREATE TABLE cache ( key text PRIMARY
Edit: I have solved this by myself. See my answer below I have set
EDIT: I have submitted a bug report and Microsoft have acknowledge that it is
EDIT i have something like this in a file: imagecolor=0 arrayimagecolorcopy=0 arrayimagecolorcopy3d=0 when i
I don't know how to query this one out. I have a table structure
EDIT: Optimization results at end of this question! hi, i have a following code
I have a table that contains partial data that is of no use to
I'm doing a mysql table and i have one column that has current timestamp
In my code I have a query that looks like this: $load_query = LOAD
I have a SQLite table with a Balance field that will be used as

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.