0
votes

I am having problem fetching data by using doctrine with native sql, below code works fine on my local development machine but when I test it online. I get

Oops! An Error Occurred The server returned a "500 Internal Server Error". Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.

Here is my query in controller:-

$em = $this->getDoctrine()->getManager();
$connection = $em->getConnection();    
$statement = $connection->prepare("SELECT * FROM students");  
$statement->execute( );
$results = $statement->fetchAll();

return $this->render('MobileLearnerBundle:Default:test_page.html.twig', array('results'=>$results));

test_page.html.twig code:-

{% for item in results %}

   {{ item.first_name }}

{{ item.last_name }}

{% endfor %}   

Thanks for the help in advance !

1
What do your logs say? - qooplmao
[2014-08-30 09:32:59] request.INFO: Matched route "mobile_learner_loginpage_customlogin" (parameters: "_controller": "Mobile\LearnerBundle\Controller\LoginPageController::CustomLoginAction", "_route": "mobile_learner_loginpage_customlogin") [] [] - Ajay Shokar
[2014-08-30 09:32:59] request.CRITICAL: Uncaught PHP Exception PDOException: "SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)" at /var/www/html/mobile/m/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php line 40 {"exception":"[object] (PDOException: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES) at /var/www/html/mobile/m/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:40)"} [] - Ajay Shokar
But My password is correct, { parameters: { database_driver: pdo_mysql, database_host: 127.0.0.1, database_port: null, database_name: symfony, database_user: root, database_password: MyPWD, mailer_transport: smtp, mailer_host: 127.0.0.1, mailer_user: null, mailer_password: null, locale: en, secret: ergegfdgfgfa7c095060d0887c675c2df1456bfb, debug_toolbar: true, debug_redirects: false, use_assetic_controller: true, database_path: null } } - Ajay Shokar
Does it work if you change the database_host to localhost? - qooplmao

1 Answers

0
votes

I think I was putting in the wrong password but now when I put in the right password I get

Invalid type for path "doctrine.dbal.connections.default.password". Expected scalar, but got object 

by running below command in my linux server

php app/console cache:clear --env=prod

Reason behind is that I have @my_password@ and when I remove " @ " from password no error but obviously then its not correct password. Is doctrine telling me that it does not allow "@" at the beginning and end of a password. I tried both ways @my_password@ and '@my_password@'