Unbekannte Feld: Benutzername, während die Abfrage Über Lehre mit ZF2

hier ist das snippet zu meinem code, wenn ich versuche, eine Abfrage wie diese

   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;

bekomme ich die folgende Fehlermeldung

Unbekannte Feld: Benutzername

Diese sind meine umfasst

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

Edit: das ist mein Thema\Entity\User Datei

 <?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
}

?>
Können Sie Ihre Album\Entity\Album Klasse?
Scheint so, als das Feld user_name existiert nicht. Haben Sie die Eigenschaft name für die Abfrage? Der Datenbank-Feldname ist nicht relevant für die Lehre, nur der name der Eigenschaft ist.
ja u beide schon richtig ich habe aktualisiert es jetzt u kann es herausfinden?

InformationsquelleAutor noobie-php | 2013-02-05

Schreibe einen Kommentar