原则2的代码点火器2-我可以将数据插入到表中,但我可以';无法取回数据


codeigniter 2 with doctrine 2 - I can insert data in to tables but I can't get data back

我仍在努力学习条令,所以我遵循在线教程,可以将数据插入到mysql表中。像这样。

public function createObjects() {
        // create a new user object
        $user = new Entities'User;
        $user->setFirstName('Joel');
        $user->setLastName('Verhagen');
        $user->setPassword(md5('Emma Watson'));
        $this->doctrine->em->persist($user);
        $this->doctrine->em->flush();
}

然后我试着像这样把数据拿回来。

public function testing() {
//        $user = new Entities'User;
        $article = new Entities'Article;
        $firstname = $this->doctrine->em->getRepository($article);
        $products = $firstname->findAll();
        foreach ($products as $product) {
            echo sprintf("-%s'n", $product->getContent());
        }
    }

但我犯了以下错误,有人能帮我吗?

Severity: Warning
Message: ltrim() expects parameter 1 to be string, object given
Filename: ORM/EntityManager.php
Severity: Warning
Message: class_parents(): object or string expected
Filename: Mapping/RuntimeReflectionService.php

Severity: Warning
Message: array_reverse() expects parameter 1 to be array, boolean given
Filename: Mapping/AbstractClassMetadataFactory.php

Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: Mapping/AbstractClassMetadataFactory.php

Fatal error: Uncaught exception 'ReflectionException' with message 'Class does not exist' in E:'xampp'htdocs'shoping'application'libraries'Doctrine'Common'Persistence'Mapping'RuntimeReflectionService.php:73 Stack trace: #0 E:'xampp'htdocs'shoping'application'libraries'Doctrine'Common'Persistence'Mapping'RuntimeReflectionService.php(73): ReflectionClass->__construct('') #1 E:'xampp'htdocs'shoping'application'libraries'Doctrine'ORM'Mapping'ClassMetadataInfo.php(867): Doctrine'Common'Persistence'Mapping'RuntimeReflectionService->getClass(NULL) #2 E:'xampp'htdocs'shoping'application'libraries'Doctrine'ORM'Mapping'ClassMetadataFactory.php(517): Doctrine'ORM'Mapping'ClassMetadataInfo->initializeReflection(Object(Doctrine'Common'Persistence'Mapping'RuntimeReflectionService)) #3 E:'xampp'htdocs'shoping'application'libraries'Doctrine'Common'Persistence'Mapping'AbstractClassMetadataFactory.php(300): Doctrine'ORM'Mapping'ClassMetadataFactory->initializeReflection(Object(Doctrine'ORM'Mapping'ClassMetadata), Object(Doctrine'Common'Pe in E:'xampp'htdocs'shoping'application'libraries'Doctrine'Common'Persistence'Mapping'RuntimeReflectionService.php on line 73

试了又试,终于找到了一条路。

public function testing() {
//        $user = new Entities'User;
        $article = new Entities'Article;
        $firstname = $this->doctrine->em->getRepository('Entities'Article');
        $products = $firstname->findAll();
        foreach ($products as $product) {
            echo sprintf("-%s'n", $product->getContent());
        }
//        $products = $article->getContent();
//        echo $products.'fdsf';
    }