findOneBy return Error 500 #6066

Open
opened 2026-01-22 15:26:01 +01:00 by admin · 0 comments
Owner

Originally created by @JosemarOdia on GitHub (Sep 11, 2018).

Originally assigned to: @Ocramius on GitHub.

Hello, when calling Doctrine's findOneBy function, I get no result and no return message. It simply gives 500 error without any message.

I'm using Doctrine with Slim Framework 3.

Parts of Composer.json:

{
    "require": {
        "doctrine / orm": "2.4. *",
        "doctrine / doctrine-module": "^ 2"
    },
    
    "autoload": {
        "psr-4": {
            "App \\ Model \\": "src / models"
        }
    }
}

Function call:
$cliente = $this->em->getRepository('App\Model\Cliente')->findOneBy(array('idCliente' => 3));

Class Cliente:

<?php

namespace App\Model;

use Doctrine\ORM\Mapping as ORM;

/**
 * Cliente
 *
 * @ORM\Table(name="cliente", indexes={@ORM\Index(name="plano", columns={"plano"})})
 * @ORM\Entity
 */
class Cliente
{
    /**
     * @var integer
     *
     * @ORM\Column(name="Id_cliente", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $idCliente;

    /**
     * @var string
     *
     * @ORM\Column(name="CNPJ", type="string", length=18, nullable=false)
     */
    private $cnpj;

    /**
     * @var string
     *
     * @ORM\Column(name="NomeFantasia", type="string", length=255, nullable=false)
     */
    private $nomefantasia;

    /**
     * @var string
     *
     * @ORM\Column(name="RazaoSocial", type="string", length=255, nullable=false)
     */
    private $razaosocial;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="ValidadeLicenca", type="datetime", nullable=false)
     */
    private $validadelicenca;

    /**
     * @var string
     *
     * @ORM\Column(name="Telefone", type="string", length=20, nullable=true)
     */
    private $telefone;

    /**
     * @var string
     *
     * @ORM\Column(name="Segmento", type="string", length=255, nullable=true)
     */
    private $segmento;

    /**
     * @var string
     *
     * @ORM\Column(name="FormaPagamento", type="string", length=0, nullable=true)
     */
    private $formapagamento;

    /**
     * @var float
     *
     * @ORM\Column(name="CupomDesconto", type="float", precision=10, scale=2, nullable=true)
     */
    private $cupomdesconto;

    /**
     * @var string
     *
     * @ORM\Column(name="InfoAdicional", type="text", length=65535, nullable=true)
     */
    private $infoadicional;

    /**
     * @var integer
     *
     * @ORM\Column(name="Status", type="integer", nullable=false)
     */
    private $status;

    /**
     * @var \App\Model\Plano
     *
     * @ORM\ManyToOne(targetEntity="App\Model\Plano")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="plano", referencedColumnName="Id_plano")
     * })
     */
    private $plano;


    /**
     * Get idCliente
     *
     * @return integer 
     */
    public function getIdCliente()
    {
        return $this->idCliente;
    }

    /**
     * Set cnpj
     *
     * @param string $cnpj
     * @return Cliente
     */
    public function setCnpj($cnpj)
    {
        $this->cnpj = $cnpj;

        return $this;
    }

    /**
     * Get cnpj
     *
     * @return string 
     */
    public function getCnpj()
    {
        return $this->cnpj;
    }

    /**
     * Set nomefantasia
     *
     * @param string $nomefantasia
     * @return Cliente
     */
    public function setNomefantasia($nomefantasia)
    {
        $this->nomefantasia = $nomefantasia;

        return $this;
    }

    /**
     * Get nomefantasia
     *
     * @return string 
     */
    public function getNomefantasia()
    {
        return $this->nomefantasia;
    }

    /**
     * Set razaosocial
     *
     * @param string $razaosocial
     * @return Cliente
     */
    public function setRazaosocial($razaosocial)
    {
        $this->razaosocial = $razaosocial;

        return $this;
    }

    /**
     * Get razaosocial
     *
     * @return string 
     */
    public function getRazaosocial()
    {
        return $this->razaosocial;
    }

    /**
     * Set validadelicenca
     *
     * @param \DateTime $validadelicenca
     * @return Cliente
     */
    public function setValidadelicenca($validadelicenca)
    {
        $this->validadelicenca = $validadelicenca;

        return $this;
    }

    /**
     * Get validadelicenca
     *
     * @return \DateTime 
     */
    public function getValidadelicenca()
    {
        return $this->validadelicenca;
    }

    /**
     * Set telefone
     *
     * @param string $telefone
     * @return Cliente
     */
    public function setTelefone($telefone)
    {
        $this->telefone = $telefone;

        return $this;
    }

    /**
     * Get telefone
     *
     * @return string 
     */
    public function getTelefone()
    {
        return $this->telefone;
    }

    /**
     * Set segmento
     *
     * @param string $segmento
     * @return Cliente
     */
    public function setSegmento($segmento)
    {
        $this->segmento = $segmento;

        return $this;
    }

    /**
     * Get segmento
     *
     * @return string 
     */
    public function getSegmento()
    {
        return $this->segmento;
    }

    /**
     * Set formapagamento
     *
     * @param string $formapagamento
     * @return Cliente
     */
    public function setFormapagamento($formapagamento)
    {
        $this->formapagamento = $formapagamento;

        return $this;
    }

    /**
     * Get formapagamento
     *
     * @return string 
     */
    public function getFormapagamento()
    {
        return $this->formapagamento;
    }

    /**
     * Set cupomdesconto
     *
     * @param float $cupomdesconto
     * @return Cliente
     */
    public function setCupomdesconto($cupomdesconto)
    {
        $this->cupomdesconto = $cupomdesconto;

        return $this;
    }

    /**
     * Get cupomdesconto
     *
     * @return float 
     */
    public function getCupomdesconto()
    {
        return $this->cupomdesconto;
    }

    /**
     * Set infoadicional
     *
     * @param string $infoadicional
     * @return Cliente
     */
    public function setInfoadicional($infoadicional)
    {
        $this->infoadicional = $infoadicional;

        return $this;
    }

    /**
     * Get infoadicional
     *
     * @return string 
     */
    public function getInfoadicional()
    {
        return $this->infoadicional;
    }

    /**
     * Set status
     *
     * @param integer $status
     * @return Cliente
     */
    public function setStatus($status)
    {
        $this->status = $status;

        return $this;
    }

    /**
     * Get status
     *
     * @return integer 
     */
    public function getStatus()
    {
        return $this->status;
    }

    /**
     * Set plano
     *
     * @param \App\Model\Plano $plano
     * @return Cliente
     */
    public function setPlano(\App\Model\Plano $plano = null)
    {
        $this->plano = $plano;

        return $this;
    }

    /**
     * Get plano
     *
     * @return \App\Model\Plano 
     */
    public function getPlano()
    {
        return $this->plano;
    }
}

Originally created by @JosemarOdia on GitHub (Sep 11, 2018). Originally assigned to: @Ocramius on GitHub. Hello, when calling Doctrine's findOneBy function, I get no result and no return message. It simply gives 500 error without any message. I'm using Doctrine with Slim Framework 3. Parts of Composer.json: ``` {     "require": {         "doctrine / orm": "2.4. *",         "doctrine / doctrine-module": "^ 2"     },          "autoload": {         "psr-4": {             "App \\ Model \\": "src / models"         }     } } ``` Function call: `$cliente = $this->em->getRepository('App\Model\Cliente')->findOneBy(array('idCliente' => 3));` Class Cliente: ``` <?php namespace App\Model; use Doctrine\ORM\Mapping as ORM; /** * Cliente * * @ORM\Table(name="cliente", indexes={@ORM\Index(name="plano", columns={"plano"})}) * @ORM\Entity */ class Cliente { /** * @var integer * * @ORM\Column(name="Id_cliente", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $idCliente; /** * @var string * * @ORM\Column(name="CNPJ", type="string", length=18, nullable=false) */ private $cnpj; /** * @var string * * @ORM\Column(name="NomeFantasia", type="string", length=255, nullable=false) */ private $nomefantasia; /** * @var string * * @ORM\Column(name="RazaoSocial", type="string", length=255, nullable=false) */ private $razaosocial; /** * @var \DateTime * * @ORM\Column(name="ValidadeLicenca", type="datetime", nullable=false) */ private $validadelicenca; /** * @var string * * @ORM\Column(name="Telefone", type="string", length=20, nullable=true) */ private $telefone; /** * @var string * * @ORM\Column(name="Segmento", type="string", length=255, nullable=true) */ private $segmento; /** * @var string * * @ORM\Column(name="FormaPagamento", type="string", length=0, nullable=true) */ private $formapagamento; /** * @var float * * @ORM\Column(name="CupomDesconto", type="float", precision=10, scale=2, nullable=true) */ private $cupomdesconto; /** * @var string * * @ORM\Column(name="InfoAdicional", type="text", length=65535, nullable=true) */ private $infoadicional; /** * @var integer * * @ORM\Column(name="Status", type="integer", nullable=false) */ private $status; /** * @var \App\Model\Plano * * @ORM\ManyToOne(targetEntity="App\Model\Plano") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="plano", referencedColumnName="Id_plano") * }) */ private $plano; /** * Get idCliente * * @return integer */ public function getIdCliente() { return $this->idCliente; } /** * Set cnpj * * @param string $cnpj * @return Cliente */ public function setCnpj($cnpj) { $this->cnpj = $cnpj; return $this; } /** * Get cnpj * * @return string */ public function getCnpj() { return $this->cnpj; } /** * Set nomefantasia * * @param string $nomefantasia * @return Cliente */ public function setNomefantasia($nomefantasia) { $this->nomefantasia = $nomefantasia; return $this; } /** * Get nomefantasia * * @return string */ public function getNomefantasia() { return $this->nomefantasia; } /** * Set razaosocial * * @param string $razaosocial * @return Cliente */ public function setRazaosocial($razaosocial) { $this->razaosocial = $razaosocial; return $this; } /** * Get razaosocial * * @return string */ public function getRazaosocial() { return $this->razaosocial; } /** * Set validadelicenca * * @param \DateTime $validadelicenca * @return Cliente */ public function setValidadelicenca($validadelicenca) { $this->validadelicenca = $validadelicenca; return $this; } /** * Get validadelicenca * * @return \DateTime */ public function getValidadelicenca() { return $this->validadelicenca; } /** * Set telefone * * @param string $telefone * @return Cliente */ public function setTelefone($telefone) { $this->telefone = $telefone; return $this; } /** * Get telefone * * @return string */ public function getTelefone() { return $this->telefone; } /** * Set segmento * * @param string $segmento * @return Cliente */ public function setSegmento($segmento) { $this->segmento = $segmento; return $this; } /** * Get segmento * * @return string */ public function getSegmento() { return $this->segmento; } /** * Set formapagamento * * @param string $formapagamento * @return Cliente */ public function setFormapagamento($formapagamento) { $this->formapagamento = $formapagamento; return $this; } /** * Get formapagamento * * @return string */ public function getFormapagamento() { return $this->formapagamento; } /** * Set cupomdesconto * * @param float $cupomdesconto * @return Cliente */ public function setCupomdesconto($cupomdesconto) { $this->cupomdesconto = $cupomdesconto; return $this; } /** * Get cupomdesconto * * @return float */ public function getCupomdesconto() { return $this->cupomdesconto; } /** * Set infoadicional * * @param string $infoadicional * @return Cliente */ public function setInfoadicional($infoadicional) { $this->infoadicional = $infoadicional; return $this; } /** * Get infoadicional * * @return string */ public function getInfoadicional() { return $this->infoadicional; } /** * Set status * * @param integer $status * @return Cliente */ public function setStatus($status) { $this->status = $status; return $this; } /** * Get status * * @return integer */ public function getStatus() { return $this->status; } /** * Set plano * * @param \App\Model\Plano $plano * @return Cliente */ public function setPlano(\App\Model\Plano $plano = null) { $this->plano = $plano; return $this; } /** * Get plano * * @return \App\Model\Plano */ public function getPlano() { return $this->plano; } } ```
admin added the Invalid label 2026-01-22 15:26:01 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6066