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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:35:05+00:00 2026-06-11T15:35:05+00:00

Hi have setup a db with tables States and StoreLocations. I have created entities

  • 0

Hi have setup a db with tables States and StoreLocations. I have created entities for both. As well as RESTful services. When posting a new Location on my local machine everything works fine.

I have deployed my project to another server and when I try to post a new Location on this machine I get the following error

Code: 23000 
Message: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`vitanica`.`StoreLocation`, CONSTRAINT `storelocation_ibfk_1` FOREIGN KEY (`state_id`) REFERENCES `state` (`id`))
File: /home/audioglobe.com/zend/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php
Line: 131 

I do not understand why this would work on one machine and not another. Thanks in advance for any thoughts on the issue!

Here are my tables:

mysql> show create table StoreLocation

| StoreLocation | CREATE TABLE `StoreLocation` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(60) DEFAULT NULL,
`address` varchar(80) DEFAULT NULL,
`city` varchar(80) DEFAULT NULL,
`state_id` int(11) DEFAULT NULL,
`zip` varchar(12) DEFAULT NULL,
`phone` varchar(20) DEFAULT NULL,
`lat` float(10,6) DEFAULT NULL,
`lng` float(10,6) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `state` (`state_id`),
CONSTRAINT `storelocation_ibfk_1` FOREIGN KEY (`state_id`) REFERENCES `state` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1 |

mysql> show create table State

| State | CREATE TABLE `State` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(10) NOT NULL,
`state` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=latin1 |

And a snippet from my Entities:

/** @Entity */ 
class State
{
  ....
    /** @OneToMany(targetEntity="StoreLocation", mappedBy="state") */
    private $stores;
}

/** @Entity @HasLifecycleCallbacks*/
class StoreLocation
{
    /**
    * @ManyToOne(targetEntity="State", inversedBy="id")
    */
    private $state;
}
  • 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-11T15:35:06+00:00Added an answer on June 11, 2026 at 3:35 pm

    It seems that the fk was failing because mysql was case-sensitive on production. The table name was State though the constraint referenced state(id). I changed all table names to lower case and added the property @Table('state') to my Entity. Now everything is working as expected! Thanks for the help guys!

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

Sidebar

Related Questions

Curious whether folks have setup 2 way transactional replication on the tables ASP.NET uses
i have a number of Tables setup in SQl Server i have transferred all
I need some advice of how to setup my tables I currently have a
Here's my toy setup. I have 3 tables. One table is a guest list
I have created a GUI that will setup the pivot table. For example, I
So here's the setup. I have two tables: CREATE TABLE dbo.TmpFeesToRules1(Name varchar, LookupId int)
I have a standard one directional master-slave setup. The tables have MyIsam storage engine.
I have two tables which both have a unique PID. I need to know
I have set up 2 two tables - table userid and table data in
I have the following setup: Table: Question QuestionId Table: QuestionTag QuestionId TagId Table: Tag

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.