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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:35:32+00:00 2026-06-18T09:35:32+00:00

here is the snippet to my code when i try to query it like

  • 0

here is the snippet to my code when i try to query it like this

   if ($request->isPost()) {
        $form->setData($request->getPost());
        if ($form->isValid()) {

            //check authentication...
            $this->getAuthService()->getAdapter()
                    ->setIdentity($request->getPost('username'))
                    ->setCredential($request->getPost('password'));

            $username = $request->getPost('username');
            $password = $request->getPost('password');
            $result = $this->getAuthService()->authenticate();

            $criteria = array("user_name" => $username,);
           $results= $this->getEntityManager()->getRepository('Subject\Entity\User')->findBy($criteria);
           print_r($results);
           exit;

i get the following error

Unrecognized field: user_name

These are my includes

Use Doctrine\ORM\EntityManager,
Album\Entity\Album;

Edit: this is my Subject\Entity\User file

 <?php

namespace Subject\Entity;

use Doctrine\ORM\Mapping as ORM;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;

/**
 * @ORM\Entity

* @ORM\Table(name="users")

* @property string $username

* @property string $password

* @property int $id

 */
class User implements InputFilterAwareInterface {

protected $_username;
protected $_password;

 /**
 * @ORM\OneToMany(targetEntity="Subject\Entity\Subject", mappedBy="user")
 * @var Collection
 */
private $subjects;

/** @ORM\Id() @ORM\Column(type="integer") @ORM\GeneratedValue(strategy="AUTO") @var int */
protected $_id;

public function __get($property) {

    return $this->$property;
}

public function __set($property, $value) {

    $this->$property = $value;
}

//Getters and setters

/** @return Collection */
public function getSubjects() {
    return $this->subjects;
}

/** @param Comment $comment */
public function addSubject(Subject $subjects) {
    $this->subjects->add($subjects);
    $subjects->setUser($this);
}


 public function __construct($subjects) {
    //Initializing collection. Doctrine recognizes Collections, not arrays!
    $this->subjects = new ArrayCollection();

}
public function getArrayCopy() {

    return get_object_vars($this);
}

public function populate($data = array()) {

    $this->_id = $data['id'];

    $this->_username = $data['username'];

    $this->_password = $data['password'];
}

public function setInputFilter(InputFilterInterface $inputFilter) {

    throw new \Exception("Not used");
}

public function getInputFilter() {

    if (!$this->inputFilter) {
        $inputFilter = new InputFilter();
        $factory = new InputFactory();
        $inputFilter->add($factory->createInput(array(
                    'name' => 'id',
                    'required' => true,
                    'filters' => array(
                        array('name' => 'Int'),
                    ),
                )));
        $inputFilter->add($factory->createInput(array(
                    'name' => 'username',
                    'required' => true,
                    'filters' => array(
                        array('name' => 'StripTags'),
                        array('name' => 'StringTrim'),
                    ),
                    'validators' => array(
                        array(
                            'name' => 'StringLength',
                            'options' => array(
                                'encoding' => 'UTF-8',
                                'min' => 1,
                                'max' => 100,
                            ),
                        ),
                    ),
                )));



        $inputFilter->add($factory->createInput(array(
                    'name' => 'password',
                    'required' => true,
                    'filters' => array(
                        array('name' => 'StripTags'),
                        array('name' => 'StringTrim'),
                    ),
                    'validators' => array(
                        array(
                            'name' => 'StringLength',
                            'options' => array(
                                'encoding' => 'UTF-8',
                                'min' => 1,
                                'max' => 100,
                            ),
                        ),
                    ),
                )));



        $this->inputFilter = $inputFilter;
    }



    return $this->inputFilter;
}

//put your code here
}

?>
  • 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-18T09:35:33+00:00Added an answer on June 18, 2026 at 9:35 am

    You are querying for the wrong field. The field is named _username in your entity class. Also check you annotations, _username and _password seem to not have any so they won’t be created as database fields.

    If you set up your entity correctly and all fields are in database you just need to query for your _username property:

     if ($request->isPost()) {
         $form->setData($request->getPost());
         $repo = $this->getEntityManager()->getRepository('Subject\Entity\User');
         if ($form->isValid()) {
             // snip ...
             $criteria = array("_username" => $username,);
             $results= $repo->findBy($criteria);
             print_r($results);
             exit;
        }
    }
    

    You user entity should look something like:

    class User implements InputFilterAwareInterface {
        /**
         * @ORM\Column(name="username", type="string", length=64, unique=true)
         */
        protected $_username;
        /**
         * @ORM\Column(name="password", type="string", length=64)
         */
        protected $_password;
    
        // snip ...
    }
    

    You may take a look at the PSR-2 standards. Underscores in method and variable names are discouraged by now.

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

Sidebar

Related Questions

I found the following code snippet here : with TClipper.Create do try AddPolygon(subject, ptSubject);
Here is my ugly little code snippet now: for i in range(5): try: self.startTime=time.time()
Stuck with a jquery ajax form submission! Here's the code snippet: Javascript/ HTML Code:
Here is the code snippet which I want to debug: When I try to
I found this code snippet here , but I just can't figure out what
Here is my code snippet: Public Function convert(ByVal robert As String) Try robert =
Here's a snippet of code I saw on the web and I'm wondering if
Here's the code snippet: public static void main (String[]arg) { char ca = 'a'
Here is my code snippet where I'am taking confidence with initialization blocks class Father{
Here is the following code-snippet I'm using in my Google Spreadsheet onEdit() function: else

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.