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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:45:56+00:00 2026-06-09T22:45:56+00:00

I’m trying to learn about using Doctrine 2 by making a very simple script

  • 0

I’m trying to learn about using Doctrine 2 by making a very simple script which fetches information from my database. The problem is that I can’t find any documentation explaining how Doctrine finds and uses my mapping entities. And so when it complains that it’s not finding an entity, I don’t know what to do to solve the problem. Consider the following structure in my www folder:

  • Doctrine/
  • Entities/
    • person.php
  • myTestPage.php

person.php

<?php

/** @Entity @Table(name="person")*/
class person
{
    /**
     * @Id @Column(type="integer")
     */
    protected $uid;
}
?>

myTestPage.php

<?php
    require "Doctrine/Doctrine/ORM/Tools/Setup.php";

    $lib = "Doctrine";
    Doctrine\ORM\Tools\Setup::registerAutoloadDirectory($lib);

    use Doctrine\ORM\Tools\Setup,
        Doctrine\ORM\EntityManager;

    $paths = array("/Entities");

    $isDevMode = true;

    $dbParams = array("driver" => "pdo_mysql",
        "host" => "myhost.ca",
        "user" => "Shawn",
        "password" => "noneofyourbusiness",
        "dbname" => "testDB");

    $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
    $em = EntityManager::create($dbParams, $config);

    $qb = $em->createQueryBuilder();
    $qb->select(array('uid'))
        ->from('person', 't');
    $query = $qb->getQuery();

    $result = $query->getResult();
    echo $result;
?>

When I visit myTestPage.php, I get the following error message:

Fatal error: Uncaught exception ‘Doctrine\ORM\Query\QueryException’
with message ‘[Semantical Error] line 0, col 24 near ‘person’:
Error: Class ‘person’ is not defined.’ in
C:\wamp\www\Doctrine\Doctrine\ORM\Query\QueryException.php on line 47

The problem seems to be that Doctrine can’t find person.php, but how can I solve this?

  • 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-09T22:45:58+00:00Added an answer on June 9, 2026 at 10:45 pm

    I don’t exactly know what the “re1_chercheur” means, but when I tried your code, it complained about person not being defined, so i included that and it worked.
    Of course, this should be dealt with by using an autoloader of some sort, but I think doctrine has some solution for that also. I haven’t been using their autoloader, because I have my own which uses the PSR compliant autoloading.

    Also in your select, if you want just the “uid”, use “t.uid”. “t” is the alias of the person class, so in other places in the query, you’ll be using “t” to get to it’s properties (you could do a ->where(“t.uid = someNumber”)). If you want the whole object use select(“t”);

    I found the doctrine documentation quite helpful, just make sure you go in the order it is laid out, and you’ll get the hang of it in no time.

    I know this is not an exact answer, but maybe it points you into the right direction.

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

Sidebar

Related Questions

I have a view passing on information from a database: def serve_article(request, id): served_article
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
I am reading a book about Javascript and jQuery and using one of the
I'm trying to select an H1 element which is the second-child in its group
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.