mysqli_connect google from engine app php google-app-engine pdo doctrine2 google-cloud-sql

php - from - google app engine sql



¿Doctrine no encuentra datos en Google App Engine? (1)

Cuando hago una consulta simple, como encontrar a todos los usuarios, devuelve una matriz vacía. $users = $em->getRepository(''MyApp//Model//Entity//User'')->findAll();

Sin embargo, cuando me conecto a mi base de datos manualmente, usando PDO, encuentra los datos. Estoy usando el método ArrayCache para asegurarme de que no tiene nada que ver con que GAE no tenga un sistema de archivos. Los documentos de GAE dicen que puedes usar sys_get_temp_dir() , así que no creo que sean mis servidores proxy. No entiendo por qué Doctrine no devuelve nada y tampoco arroja ningún error.

Aquí está mi archivo bootstrap para mi aplicación:

<?php $baseDir = dirname(dirname(__FILE__)); define(''TIMEZONE_OFFSET'', /MyApp/Library/Date::getMyTimezoneOffset()); use Doctrine/Common/Annotations/AnnotationReader; use Doctrine/Common/Annotations/AnnotationRegistry; // globally used cache driver, in production use APC or memcached $cache = new Doctrine/Common/Cache/ArrayCache; // standard annotation reader $annotationReader = new AnnotationReader; AnnotationReader::addGlobalIgnoredName(''dummy''); AnnotationRegistry::registerFile(__DIR__ . "/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); AnnotationRegistry::registerFile(__DIR__ . "/Gedmo/Timestampable/Mapping/Driver/Annotation.php"); AnnotationRegistry::registerAutoloadNamespace("//MyApp//Model//Entity", $baseDir); $cachedAnnotationReader = new Doctrine/Common/Annotations/CachedReader( $annotationReader, // use reader $cache, // and a cache driver $debug = LOCAL ); // create a driver chain for metadata reading $driverChain = new Doctrine/ORM/Mapping/Driver/DriverChain(); // load superclass metadata mapping only, into driver chain // also registers Gedmo annotations.NOTE: you can personalize it Gedmo/DoctrineExtensions::registerAbstractMappingIntoDriverChainORM( $driverChain, // our metadata driver chain, to hook into $cachedAnnotationReader // our cached annotation reader ); // now we want to register our application entities, // for that we need another metadata driver used for Entity namespace $annotationDriver = new Doctrine/ORM/Mapping/Driver/AnnotationDriver( $cachedAnnotationReader, // our cached annotation reader array(ENTITY_PATH) // paths to look in ); // NOTE: driver for application Entity can be different, Yaml, Xml or whatever // register annotation driver for our application Entity namespace $driverChain->addDriver($annotationDriver, ''MyApp//Model//Entity''); // general ORM configuration $config = new Doctrine/ORM/Configuration; $config->setProxyDir(sys_get_temp_dir()); $config->setProxyNamespace(''Proxy''); $config->setAutoGenerateProxyClasses(Doctrine/Common/Proxy/AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS); // this can be based on production config. // register metadata driver $config->setMetadataDriverImpl($driverChain); // use our already initialized cache driver $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); // create event manager and hook preferred extension listeners $evm = new Doctrine/Common/EventManager(); // gedmo extension listeners, remove which are not used // timestampable $timestampableListener = new Gedmo/Timestampable/TimestampableListener; $timestampableListener->setAnnotationReader($cachedAnnotationReader); $evm->addEventSubscriber($timestampableListener); // mysql set names UTF-8 if required $evm->addEventSubscriber(new Doctrine/DBAL/Event/Listeners/MysqlSessionInit()); $dbParams = array( ''driver'' => ''pdo_mysql'', ''user'' => DB_USER, ''password'' => DB_PASSWORD, ''dbname'' => DB_NAME, ''host'' => DB_HOST, ''port'' => DB_PORT, ''unix_socket'' => DB_UNIX_SOCKET ); // Finally, create entity manager $em = Doctrine/ORM/EntityManager::create($dbParams, $config, $evm);

Actualizar

Solo por claridad:

Esto devuelve una matriz vacía:

$users = $em->getRepository(''MyApp//Model//Entity//User'')->findAll(); /Doctrine/Common/Util/Debug::dump($users);

Y esto devuelve una matriz con usuarios en ella. Muy confundido.

$pdo = $em->getConnection(); $users = $pdo->query(''SELECT * FROM user''); var_dump($users->fetchAll());