0

Buenas este es mi codigo:

<?php

namespace App\Command;
use Doctrine\ORM\EntityManagerInterface;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class TrazaCommand extends Command
{
    protected static $defaultName = 'Traza';
    /** @var EntityManagerInterface */
    private $entityManager;

    public function __construct(EntityManagerInterface $entityManager)
    {
        $this->entityManager = $entityManager;
        parent::__construct(self::$defaultName);
    }
    protected function configure()
    {
        $this
            ->setDescription('Add a short description for your command')
            ->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
            ->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {

        $manager=fopen('C:\xampp\htdocs\sgisi-master\public\x.txt','r');
        $repository = $this->entityManager->getRepository('App:URLExcluir');
        while (!feof($manager)){
            $cadena= fgets($manager);
            $cadena = preg_replace('/[\s]+/', ' ', $cadena);
            $array=explode(" ", $cadena);
            if($array[3] == "TCP_MISS/200"){
                $url = ($array[6]);
                $urldb = $repository->findOneBy(URL,$url);
                if (null != $urldb){
                    print_r ($array);
                }
            }
        }
    }
}

En la linea : $urldb = $repository->findOneByURL($url); obtengo este error

Entity 'App\Entity\URLExcluir' has no field 'uRL'. You can therefore not ca
  ll 'findOneByURL' on the entities' repository

y la cambie por este $urldb = $repository->findOneBy(Url,$url);y ahora sale esto

 Warning: Use of undefined constant URL - assumed 'URL' (this will throw an
  Error in a future version of PHP)

y ya no se como mas poner para que me busque esa url en mi base de datos.si alguien pudiese ayudarme a coooregir el problema.

2 respuestas 2

0

Te dejo el link a la documentación y como se debería pasar los datos de manera correcta.

Pasar los datos:

$product = $repository->findOneBy(['name' => 'Keyboard']);

Adaptalo a tú necesidad

Documentacíon

0

En tu caso sería algo como así:

$urldb = $repository->findOneBy(['url' => $url]);

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.