doctrine

PHP Fatal error: Uncaught Error: Class not found

China☆狼群 提交于 2021-02-05 12:13:14
问题 I am trying to go trough tutorial of doctrine here is official website. And I got an error in Starting with the Product Entity part. This is what I write to terminal: $ php create_product.php ORM PHP Fatal error: Uncaught Error: Class 'product' not found in /home/vaclav/Server/vssk/VSSK/project/create_product.php:8 Stack trace: #0 {main} thrown in /home/vaclav/Server/vssk/VSSK/project/create_product.php on line 8 回答1: Solved with adding: require_once 'patch_to_your_class/Product.php'; to

PHP Fatal error: Uncaught Error: Class not found

℡╲_俬逩灬. 提交于 2021-02-05 12:11:41
问题 I am trying to go trough tutorial of doctrine here is official website. And I got an error in Starting with the Product Entity part. This is what I write to terminal: $ php create_product.php ORM PHP Fatal error: Uncaught Error: Class 'product' not found in /home/vaclav/Server/vssk/VSSK/project/create_product.php:8 Stack trace: #0 {main} thrown in /home/vaclav/Server/vssk/VSSK/project/create_product.php on line 8 回答1: Solved with adding: require_once 'patch_to_your_class/Product.php'; to

The class was not found in the chain configured namespaces

ε祈祈猫儿з 提交于 2021-01-29 12:51:44
问题 Hello, i need to explain what i'm was doing at first: I was on a project and for some reason I ended up having to use two databases instead of just one. so i do what it was needed to do, i change my doctrine.yaml settings with what is explain in the symfony doc and in that moment the error appeared An SQL error that says that it was no column found for X request on X table (the error is SQLSTATE[42S02], but it's not important) (in parallel of that error i need to say that the "--em" shit didn

Doctrine return error with “eq”, no with “in”

给你一囗甜甜゛ 提交于 2021-01-29 08:33:46
问题 With Symfony and Doctrine, I have an error with "eq" subquery : It's OK, no error : public function getForums() { $qb = $this->createQueryBuilder('fc'); return $qb ->innerJoin('fc.versions', 'fcv') ->innerJoin('fc.versions', 'fcvl', 'WITH', $qb->expr()->in( 'fcvl.id', $this->_em->createQueryBuilder() ->select('MAX(v.id)') ->from(ForumCategoryVersion::class, 'v') ->where('v.forumCategory = fc') ->getDQL() )) ->select('fc, fcv') ->getQuery() ->getResult(); } Replace in by eq : public function

How to efficiently load last item in ArrayCollection?

泪湿孤枕 提交于 2021-01-29 08:00:18
问题 I have the following 2 entities: public class Domain { ... /** * @ORM\OneToMany(targetEntity="Application\Entity\Ping", mappedBy="domain", cascade={"persist", "remove"}, fetch="EXTRA_LAZY") * @ORM\OrderBy({"time" = "ASC"}) */ private $pings; ... } and: class Ping{ ... /** * @ORM\ManyToOne(targetEntity="Application\Entity\Domain", inversedBy="pings") * @ORM\JoinColumn(name="proj_id", referencedColumnName="proj_id") */ private $domain; ... } I have currently a couple of hundred domains with 5K

Create form of Category with SubCategories on Symfony

筅森魡賤 提交于 2021-01-28 12:03:28
问题 I have two entities : Category and SubCategory. One category have 0 or many subcategory. They are related with Many-to-One relation. I don't imagine how i can make a form with subcategories group by category like this : CATEGORY 1 : - SubCategory 1 - SubCategory 2 CATEGORY 2: - SubCategory 1 - SubCategory 2 My form actual : class CategorieType extends AbstractType { /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder,

WHERE … IN query with sub-query in Doctrine queryBuilder or equivalent

穿精又带淫゛_ 提交于 2021-01-28 07:01:34
问题 In my Symfony 4 project I have a User entity and a UserRepository . I'm trying to implement the equivalent of this SQL query in the QueryBuilder (Doctrine 2) or even in DQL . SELECT * FROM user WHERE account_manager_id IN (SELECT id FROM user WHERE account_manager_id = :managerAdminId AND roles LIKE '%ROLE_MANAGER%') Or maybe use a different syntax. I tried different things, but couldn't figure out how to write the WHERE ... IN with the sub-query. This is all I could come up with, which I don

Symfony Doctrine update query fail

浪尽此生 提交于 2021-01-28 05:33:35
问题 My code is: $query = $em->createQuery("UPDATE AppBundle:Project u SET u.name=1, u.key=?2, u.leader=?3 WHERE u.id = ?4"); $query->setParameter(1, $project->name); $query->setParameter(2, $project->key); $query->setParameter(3, $project->lead->name); $query->setParameter(4, $project->id); $result = $query->getResult(); Now when I run it, it gives me a error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your

DQL query returns: StateFieldPathExpression or SingleValuedAssociationField expected

跟風遠走 提交于 2021-01-28 02:51:00
问题 I have the following DQL query: public function findByIdJoinedToCodeExample($pageId) { $query = $this->getEntityManager() ->createQuery(' SELECT c FROM acmeStyleGuideBundle:codeExample c JOIN c.PageContent p WHERE p.codeExample = :cex' ) ->setParameter('cex', $pageId); try { return $query->getResult(); } catch (\Doctrine\ORM\NoResultException $e) { return null; } } It is attempting to retreive data from an entity called codeExample which has a ManyToOne relationship with an entity called

DQL query returns: StateFieldPathExpression or SingleValuedAssociationField expected

主宰稳场 提交于 2021-01-27 23:50:00
问题 I have the following DQL query: public function findByIdJoinedToCodeExample($pageId) { $query = $this->getEntityManager() ->createQuery(' SELECT c FROM acmeStyleGuideBundle:codeExample c JOIN c.PageContent p WHERE p.codeExample = :cex' ) ->setParameter('cex', $pageId); try { return $query->getResult(); } catch (\Doctrine\ORM\NoResultException $e) { return null; } } It is attempting to retreive data from an entity called codeExample which has a ManyToOne relationship with an entity called