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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:43:38+00:00 2026-06-02T06:43:38+00:00

I’m using Doctrine2+CodeIgniter2, and am attempting to create a simple test of a join

  • 0

I’m using Doctrine2+CodeIgniter2, and am attempting to create a simple test of a join table.

Here is my schema for the two tables involved:

CREATE TABLE test_lastnames (id INT AUTO_INCREMENT NOT NULL, last_name
VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB;

CREATE TABLE test_firstnames (id INT AUTO_INCREMENT NOT NULL,
mylastname_id INT DEFAULT NULL, first_name VARCHAR(255) NOT NULL,
INDEX IDX_23D7305696EC0FA4 (mylastname_id), PRIMARY KEY(id)) ENGINE =
InnoDB;

ALTER TABLE test_firstnames ADD CONSTRAINT FK_23D7305696EC0FA4 FOREIGN
KEY (mylastname_id) REFERENCES test_lastnames (id)

Here are my YAML mappings

ORM\Testing\Firstnames:
  type: entity
  table: test_firstnames
  fields:
    id:
      type: integer
      id: true
      generator:
        strategy: AUTO
    firstname:
      type: string
      column: first_name
  manyToOne:
    mylastname:
      targetEntity: ORM\Testing\Lastnames

and

ORM\Testing\Lastnames:
  type: entity
  table: test_lastnames
  fields:
    id:
      type: integer
      id: true
      generator:
        strategy: AUTO
    lastname:
      type: string
      column: last_name

I am attempting to write data to the tables.

$new_lastname = new ORM\Testing\Lastnames;
$new_lastname -> setLastName ('Shakespear');
$this->doctrine->em->persist($new_lastname);
$this->doctrine->em->flush();

$new_firstname = new ORM\Testing\Firstnames;
$new_firstname->setFirstname('William');
$new_firstname->setMyLastName($new_lastname ->getID());
$this->doctrine->em->persist($new_firstname);
$this->doctrine->em->flush();

It returns the following errors:

Message: Argument 1 passed to ORM\Testing\Firstnames::setMylastname() must be an instance of ORM\Testing\Lastnames, integer given, called in /[PATH]/applicationFolder/controllers/testing/test_namejoins_insert.php on line 31 and defined

Filename: Testing/Firstnames.php

Line Number: 66

As well as a bunch of Message: spl_object_hash() expects parameter 1 to be object, integer given errors.

Here is line 66 from Firstnames.php: public function setMylastname(\ORM\Testing\Lastnames $mylastname = null)

I have not started hacking at it – is the problem right there with ‘$mylastname = null’?

How does one insert a foreign key value by entity?

  • 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-02T06:43:39+00:00Added an answer on June 2, 2026 at 6:43 am
    $new_firstname->setMyLastName($new_lastname);
    

    rather than $new_firstname->setMyLastName($new_lastname ->getID());

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

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.