pdo exception when trying to access firebird - php

I have to access firebird with php and zend framework 2 and I'm having the following error:
/var/www/html/cad/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver /Pdo/Statement.php:187
Message:
SQLSTATE[HY000]: General error: -204 Dynamic SQL Error SQL error code = -204 Table unknown pessoa At line 1, column 19
Stack trace:
#0 /var/www/html/cad/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver /Pdo/Statement.php(187): PDO->prepare('SELECT "pessoa"...')
#1 /var/www/html/cad/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Statement.php(213): Zend\Db\Adapter\Driver\Pdo\Statement->prepare()
#2 /var/www/html/cad/vendor/zendframework/zendframework/library/Zend/Db/TableGateway/AbstractTableGateway.php(233): Zend\Db\Adapter\Driver\Pdo\Statement->execute()
#3 /var/www/html/cad/vendor/zendframework/zendframework/library/Zend/Db/TableGateway/AbstractTableGateway.php(208): Zend\Db\TableGateway\AbstractTableGateway->executeSelect(Object(Zend\Db\Sql\Select))
#4 /var/www/html/cad/vendor/zendframework/zendframework/library/Zend/Db/TableGateway/AbstractTableGateway.php(195): Zend\Db\TableGateway\AbstractTableGateway->selectWith(Object(Zend\Db\Sql\Select))
#5 /var/www/html/cad/module/Pessoa/src/Pessoa/Model/PessoaTable.php(18): Zend\Db\TableGateway\AbstractTableGateway->select()
#6 /var/www/html/cad/module/Pessoa/src/Pessoa/Controller/PessoaController.php(26): Pessoa\Model\PessoaTable->fetchAll()
#7 /var/www/html/cad/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractActionController.php(83): Pessoa\Controller\PessoaController->indexAction()
#8 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#9 /var/www/html/cad/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#10 /var/www/html/cad/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#11 /var/www/html/cad/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#12 /var/www/html/cad/vendor/zendframework/zendframework/library/Zend/Mvc/DispatchListener.php(114): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#13 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#14 /var/www/html/cad/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#15 /var/www/html/cad/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#16 /var/www/html/cad/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php(313): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#17 /var/www/html/cad/public/index.php(17): Zend\Mvc\Application->run()
#18 {main}
Global.php
return array(
'db' => array(
'driver' => 'Pdo',
'dsn' => 'firebird:dbname=/opt/bancos/teste.fdb', //array(PDO::ATTR_PERSISTENT => true),
/*'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
),*/
),
'service_manager' => array(
'factories' => array(
'Zend\Db\Adapter\Adapter'
=> 'Zend\Db\Adapter\AdapterServiceFactory',
),
),
);
?>
local.php
<?php
return array(
'db' => array(
'username' => 'sysdba',
'password' => 'masterkey',
),
);
?>
PessoaController.php
public function indexAction()
{
return new ViewModel(array(
'pessoas' => $this->getPessoaTable()->fetchAll(),
));
}
PessoaTable.php
public function fetchAll()
{
try{
$resultSet = $this->tableGateway->select();
} catch(Exception $e){
$e->getMessage();
}
return $resultSet;
}
and here is the method getPessoaTable()
public function getPessoaTable()
{
if (!$this->pessoaTable) {
$sm = $this->getServiceLocator();
$this->pessoaTable = $sm->get('Pessoa\Model\PessoaTable');
}
return $this->pessoaTable;
}
I have configured pdo_firebird.so in php. And it shows up on phpinfo()

The important part of the error is: "Table unknown pessoa". You are selecting from a table pessoa, no such table exists according to Firebird. The fact that pessoa is lower case in the error message shows you are using quoted identifiers. Quoted identifiers are case sensitive in Firebird. Unquoted identifiers are upper cased to make them case insensitive.
So this error either means the table really doesn't exist, or - as you use quoted identifiers - the table name is actually PESSOA. The rules Firebird uses for quoted/unquoted identifiers will make SELECT ... FROM pessoa work, but SELECT ... FROM "pessoa" fail.
I don't know PDO, so I can't give a PDO specific help, but I hope this narrows it down for you.

Related

swiftmailer and Yii2 not working 1 out of 10 time

I have a background process sending email to me when specific event occur.
It's working most of the time (9 out of 10), but sometime I get the following error message :
PHP Warning 'yii\base\ErrorException' with message 'fwrite(): SSL: An established connection was aborted by the software in your host machine.'
in E:\ProgramData\htdocs\Yii2_KB\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php:232
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleError(2, 'fwrite(): SSL: ...', 'E:\ProgramData\...', 232, Array)
#1 E:\ProgramData\htdocs\Yii2_KB\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php(232): fwrite(Resource id #481, 'MAIL FROM:<MTE#...')
#2 E:\ProgramData\htdocs\Yii2_KB\vendor\swiftmailer\swiftmailer\lib\classes\Swift\ByteStream\AbstractFilterableInputStream.php(171): Swift_Transport_StreamBuffer->_commit('MAIL FROM:<MTE#...')
#3 E:\ProgramData\htdocs\Yii2_KB\vendor\swiftmailer\swiftmailer\lib\classes\Swift\ByteStream\AbstractFilterableInputStream.php(90): Swift_ByteStream_AbstractFilterableInputStream->_doWrite('MAIL FROM:<MTE#...')
#4 E:\ProgramData\htdocs\Yii2_KB\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php(276): Swift_ByteStream_AbstractFilterableInputStream->write('MAIL FROM:<MTE#...')
#5 E:\ProgramData\htdocs\Yii2_KB\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\EsmtpTransport.php(243): Swift_Transport_AbstractSmtpTransport->executeCommand('MAIL FROM:<MTE#...', Array, Array)
#6 E:\ProgramData\htdocs\Yii2_KB\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\EsmtpTransport.php(322): Swift_Transport_EsmtpTransport->executeCommand('MAIL FROM:<MTE#...', Array)
#7 E:\ProgramData\htdocs\Yii2_KB\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php(416): Swift_Transport_EsmtpTransport->_doMailFromCommand('MTE#...')
#8 E:\ProgramData\htdocs\Yii2_KB\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php(444): Swift_Transport_AbstractSmtpTransport->_doMailTransaction(Object(Swift_Message), 'MTE#...', Array, Array)
#9 E:\ProgramData\htdocs\Yii2_KB\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php(176): Swift_Transport_AbstractSmtpTransport->_sendTo(Object(Swift_Message), 'MTE#...', Array, Array)
#10 E:\ProgramData\htdocs\Yii2_KB\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Mailer.php(85): Swift_Transport_AbstractSmtpTransport->send(Object(Swift_Message), Array)
#11 E:\ProgramData\htdocs\Yii2_KB\vendor\yiisoft\yii2-swiftmailer\Mailer.php(146): Swift_Mailer->send(Object(Swift_Message))
#12 E:\ProgramData\htdocs\Yii2_KB\vendor\yiisoft\yii2\mail\BaseMailer.php(260): yii\swiftmailer\Mailer->sendMessage(Object(yii\swiftmailer\Message))
#13 E:\ProgramData\htdocs\Yii2_KB\vendor\yiisoft\yii2\mail\BaseMessage.php(48): yii\mail\BaseMailer->send(Object(yii\swiftmailer\Message))
#14 E:\ProgramData\htdocs\Yii2_KB\controllers\BackgroundTask.php(172): yii\mail\BaseMessage->send()
#15 E:\ProgramData\htdocs\Yii2_KB\vendor\bazilio\yii2-async\commands\AsyncWorkerCommand.php(29): app\controllers\BackgroundTask->execute()
#16 [internal function]: bazilio\async\commands\AsyncWorkerCommand->actionDaemon('background')
#17 E:\ProgramData\htdocs\Yii2_KB\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array)
#18 E:\ProgramData\htdocs\Yii2_KB\vendor\yiisoft\yii2\base\Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#19 E:\ProgramData\htdocs\Yii2_KB\vendor\yiisoft\yii2\console\Controller.php(91): yii\base\Controller->runAction('daemon', Array)
#20 E:\ProgramData\htdocs\Yii2_KB\vendor\yiisoft\yii2\base\Module.php(455): yii\console\Controller->runAction('daemon', Array)
#21 E:\ProgramData\htdocs\Yii2_KB\vendor\yiisoft\yii2\console\Application.php(167): yii\base\Module->runAction('async-worker/da...', Array)
#22 E:\ProgramData\htdocs\Yii2_KB\vendor\yiisoft\yii2\console\Application.php(143): yii\console\Application->runAction('async-worker/da...', Array)
#23 E:\ProgramData\htdocs\Yii2_KB\vendor\yiisoft\yii2\base\Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#24 E:\ProgramData\htdocs\Yii2_KB\yii(23): yii\base\Application->run()
#25 {main}
PHP Warning: fwrite(): SSL operation failed with code 1. OpenSSL Error messages:
error:1409F07F:SSL routines:SSL3_WRITE_PENDING:bad write retry in E:\ProgramData\htdocs\Yii2_KB\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php on line 232
Here follow my configuration for the mailer :
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'x.x.x.xxx',
'username' => 'xxx',
'password' => 'XyXyXy',
'port' => '25',
'encryption' => 'tls',
],
],
I'm using Yii 2.0.6
PHP Version : 5.5.9
Mail server : Exchange Server 2010
When it fail, it's mostly after a period of inactivity between 2 events ( a few hours).
Any ideas ?
Thanks to ineersa for the tips.
I've added the following code in the beginning of the background process, and now it's working.
if (Yii::$app->mailer->getTransport()->isStarted()) {
Yii::$app->mailer->getTransport()->stop();
}
Yii::$app->mailer->getTransport()->start();

Extending ZfcUser's UserController in custom User's module

I have read Extending ZfcUser's UserController in custom module and and did everything as it was written but I still getting error:
/vagrant/app/vendor/zf-commons/zfc-user/src/ZfcUser/Controller/UserController.php:69
You must supply a callable redirectCallback
Stack trace:
#0 /vagrant/app/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php(207): ZfcUser\Controller\UserController->__construct()
#1 /vagrant/app/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(642): Zend\ServiceManager\AbstractPluginManager->createFromInvokable('zfcuser', 'zfcuser')
#2 /vagrant/app/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(598): Zend\ServiceManager\ServiceManager->doCreate('zfcuser', 'zfcuser')
#3 /vagrant/app/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(530): Zend\ServiceManager\ServiceManager->create(Array)
#4 /vagrant/app/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php(116): Zend\ServiceManager\ServiceManager->get('zfcuser', false)
#5 /vagrant/app/vendor/zendframework/zend-mvc/src/Controller/ControllerManager.php(137): Zend\ServiceManager\AbstractPluginManager->get('zfcuser', Array, false)
#6 /vagrant/app/vendor/zendframework/zend-mvc/src/Controller/Plugin/Forward.php(121): Zend\Mvc\Controller\ControllerManager->get('zfcuser')
#7 /vagrant/app/vendor/socalnick/scn-social-auth/src/ScnSocialAuth/Controller/UserController.php(118): Zend\Mvc\Controller\Plugin\Forward->dispatch('zfcuser', Array)
#8 /vagrant/app/vendor/zendframework/zend-mvc/src/Controller/AbstractActionController.php(82): ScnSocialAuth\Controller\UserController->loginAction()
#9 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#10 /vagrant/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(444): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#11 /vagrant/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#12 /vagrant/app/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(118): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#13 /vagrant/app/vendor/zendframework/zend-mvc/src/DispatchListener.php(93): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#14 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#15 /vagrant/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(444): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#16 /vagrant/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#17 /vagrant/app/vendor/zendframework/zend-mvc/src/Application.php(314): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#18 /vagrant/app/public/index.php(21): Zend\Mvc\Application->run()
#19 {main}
In MyModule\Module.php I did like this:
public function getControllerConfig()
{
return array(
'factories' => array(
'User\Controller\User' => function($controllerManager) {
$serviceManager = $controllerManager->getServiceLocator();
$redirectCallback = $serviceManager->get('zfcuser_redirect_callback');
$controller = new \ZfcUser\Controller\UserController($redirectCallback);
return $controller;
},
),
);
}
My extended User Controller looks like:
class UserController extends \ZfcUser\Controller\UserController {
public function loginAction() {
// customs actions
}
I also included ScnSocialAuth module that have own UserController.
Why I want to do it that way? I'm writing SPA application (Backbone+Marionette) and I need modal authentication. Maybe I missed something, or something wrong call - please help fix. I tried different ways but this would be the most optimal. In addition, the answer will be useful to other users. Thanks.
Controllers have their own config:
public function getControllerConfig()
{
return [
'factories' => [
// snip
Your error message says createFromInvokable in the trace. Make sure you don't have an invokable with the same locator name.
Also, your factory is returning the ZfcUser controller, not your custom one.
In order to extend ZfcUser controller in Module.php must be:
public function getControllerConfig()
{
return array(
'factories' => array(
'User\Controller\User' => function($controllerManager) {
$serviceManager = $controllerManager->getServiceLocator();
$redirectCallback = $serviceManager->get('zfcuser_redirect_callback');
$controller = new \User\Controller\UserController($redirectCallback);
return $controller;
},
),
);
}
and need to call custom user class instead zfcuser. Also my mistake was that in my module.config.php was it:
'controllers' => array(
'invokables' => array(
'User\Controller\User' => 'User\Controller\UserController'
),
),
Because of this, my factory is not called.

Cannot log into Magento 1.8.1 admin

I have just recently installed Magento 1.8.1 on a LAMP environment. Upon my first attempt to login to the admin area I got an error message. This is what I found in the error in var/report:
a:5:{i:0;s:24:"Currency 'GBP' not found";i:1;s:3536:"#0 /home/dlsb/public_html/app/code/core/Mage/Core/Model/Locale.php(587): Zend_Currency->__construct('GBP')
#1 /home/dlsb/public_html/app/code/core/Mage/Directory/Model/Currency.php(270): Mage_Core_Model_Locale->currency('GBP')
#2 /home/dlsb/public_html/app/code/core/Mage/Directory/Model/Currency.php(242): Mage_Directory_Model_Currency->formatTxt(NULL, Array)
#3 /home/dlsb/public_html/app/code/core/Mage/Directory/Model/Currency.php(222): Mage_Directory_Model_Currency->formatPrecision(NULL, 2, Array, true, false)
#4 /home/dlsb/public_html/app/code/core/Mage/Adminhtml/Block/Dashboard/Bar.php(82): Mage_Directory_Model_Currency->format(NULL)
#5 /home/dlsb/public_html/app/code/core/Mage/Adminhtml/Block/Dashboard/Bar.php(62): Mage_Adminhtml_Block_Dashboard_Bar->format(NULL)
#6 /home/dlsb/public_html/app/code/core/Mage/Adminhtml/Block/Dashboard/Totals.php(74): Mage_Adminhtml_Block_Dashboard_Bar->addTotal('Revenue', NULL)
#7 /home/dlsb/public_html/app/code/core/Mage/Core/Block/Abstract.php(293): Mage_Adminhtml_Block_Dashboard_Totals->_prepareLayout()
#8 /home/dlsb/public_html/app/code/core/Mage/Core/Model/Layout.php(456): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#9 /home/dlsb/public_html/app/code/core/Mage/Adminhtml/Block/Dashboard.php(50): Mage_Core_Model_Layout->createBlock('adminhtml/dashb...')
#10 /home/dlsb/public_html/app/code/core/Mage/Core/Block/Abstract.php(293): Mage_Adminhtml_Block_Dashboard->_prepareLayout()
#11 /home/dlsb/public_html/app/code/core/Mage/Core/Model/Layout.php(456): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#12 /home/dlsb/public_html/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('adminhtml/dashb...', 'dashboard')
#13 /home/dlsb/public_html/app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('adminhtml/dashb...', 'dashboard')
#14 /home/dlsb/public_html/app/code/core/Mage/Core/Model/Layout.php(205): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#15 /home/dlsb/public_html/app/code/core/Mage/Core/Model/Layout.php(210): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#16 /home/dlsb/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks()
#17 /home/dlsb/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(269): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#18 /home/dlsb/public_html/app/code/core/Mage/Adminhtml/Controller/Action.php(275): Mage_Core_Controller_Varien_Action->loadLayout(NULL, true, true)
#19 /home/dlsb/public_html/app/code/core/Mage/Adminhtml/controllers/DashboardController.php(40): Mage_Adminhtml_Controller_Action->loadLayout()
#20 /home/dlsb/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_DashboardController->indexAction()
#21 /home/dlsb/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#22 /home/dlsb/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#23 /home/dlsb/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#24 /home/dlsb/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#25 /home/dlsb/public_html/index.php(87): Mage::run('', 'store')
#26 {main}";s:3:"url";s:70:"/index.php/admin/dashboard/index/key/6dafbe1266347635735b10354e511cc5/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:5:"admin";}
After a bit of Googling I read a few posts advising to delete data from:
var/cache
var/session
var/locks
var/report
and to restart apache then to clear the browser cache. After doing all of this the issue still persists. Please help.
Open this file > app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
go to line 88 [in my app]
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath()
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
Comment the lines as shown below
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath()
//'domain' => $cookie->getConfigDomain(),
//'secure' => $cookie->isSecure(),
//'httponly' => $cookie->getHttponly()
);

Zend framework 2 : " Connect Error: SQLSTATE[28000] [1045] Access denied"

I have been working on the official tutorial for ZF2.
At the end of the page, to see what gives the result, I get this long error:
An error occurred
An error occurred during execution; please try again later.
Additional information:
Zend\Db\Adapter\Exception\RuntimeException
File:
D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Connection.php:243
Message:
Connect Error: SQLSTATE[28000] [1045] Access denied for user ''#'localhost' (using password: NO)
Stack trace:
#0 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Pdo.php(211): Zend\Db\Adapter\Driver\Pdo\Connection->connect()
#1 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Adapter.php(175): Zend\Db\Adapter\Driver\Pdo\Pdo->createStatement(NULL)
#2 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\Sql\Sql.php(103): Zend\Db\Adapter\Adapter->createStatement()
#3 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(234): Zend\Db\Sql\Sql->prepareStatementForSqlObject(Object(Zend\Db\Sql\Select))
#4 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(210): Zend\Db\TableGateway\AbstractTableGateway->executeSelect(Object(Zend\Db\Sql\Select))
#5 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(197): Zend\Db\TableGateway\AbstractTableGateway->selectWith(Object(Zend\Db\Sql\Select))
#6 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\module\Album\src\Album\Model\AlbumTable.php(24): Zend\Db\TableGateway\AbstractTableGateway->select()
#7 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\module\Album\src\Album\Controller\AlbumController.php(18): Album\Model\AlbumTable->fetchAll()
#8 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(87): Album\Controller\AlbumController->indexAction()
#9 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#10 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(469): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#11 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(209): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#12 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractController.php(108): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#13 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Mvc\DispatchListener.php(114): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#14 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#15 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(469): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#16 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(209): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#17 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(298): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#18 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\public\index.php(12): Zend\Mvc\Application->run()
#19 {main}
Previous exceptions:
PDOException
File:
D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Connection.php:239
Message:
SQLSTATE[28000] [1045] Access denied for user ''#'localhost' (using password: NO)
Stack trace:
#0 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Connection.php(239): PDO->__construct('mysql:dbname=zf...', NULL, NULL, Array)
#1 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Driver\Pdo\Pdo.php(211): Zend\Db\Adapter\Driver\Pdo\Connection->connect()
#2 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\Adapter\Adapter.php(175): Zend\Db\Adapter\Driver\Pdo\Pdo->createStatement(NULL)
#3 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\Sql\Sql.php(103): Zend\Db\Adapter\Adapter->createStatement()
#4 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(234): Zend\Db\Sql\Sql->prepareStatementForSqlObject(Object(Zend\Db\Sql\Select))
#5 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(210): Zend\Db\TableGateway\AbstractTableGateway->executeSelect(Object(Zend\Db\Sql\Select))
#6 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Db\TableGateway\AbstractTableGateway.php(197): Zend\Db\TableGateway\AbstractTableGateway->selectWith(Object(Zend\Db\Sql\Select))
#7 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\module\Album\src\Album\Model\AlbumTable.php(24): Zend\Db\TableGateway\AbstractTableGateway->select()
#8 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\module\Album\src\Album\Controller\AlbumController.php(18): Album\Model\AlbumTable->fetchAll()
#9 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(87): Album\Controller\AlbumController->indexAction()
#10 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#11 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(469): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#12 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(209): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#13 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractController.php(108): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#14 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Mvc\DispatchListener.php(114): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#15 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#16 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(469): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#17 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(209): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#18 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(298): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#19 D:\softs\UwAmp\www\zf2-tutorial\ZendSkeletonApplication\public\index.php(12): Zend\Mvc\Application->run()
#20 {main}
Can anyone help me on this?
You need put your credentials in a local config file
// config/autoload/local.php:
return array(
'db' => array(
'username' => 'YOUR USERNAME HERE',
'password' => 'YOUR PASSWORD HERE',
),
);
Thank Maks3w, I got the same error because I didn't create local.php file to add the code. I thought that local.php.dist works well.
Everything's great after I have the local.php with the code
// config/autoload/local.php:
return array(
'db' => array(
'username' => 'YOUR USERNAME HERE',
'password' => 'YOUR PASSWORD HERE',
),
);
There is a comment in local.php.dist that helped me to fix it:
// Copy this file without the .dist extension at the end and populate values as needed.

zend doctrine couldn't find class

Executing in method checkUnique the line $res=$select->fetchArray(); in the following class I get an error which I cannot solve.
I think it is due to the naming conventions zend autoloader
class Twit_Model_Owners extends Twit_Model_BaseOwners {
function checkUnique($username) {
$con = Doctrine_Manager::getInstance()->connection();
$select = $con->createQuery();
$select->from($this->getTable()->getTableName(), array('loginName'))
->where('loginName=?', $username);
$res=$select->fetchArray();
if (empty($res)) {
return true;
}
return false;
}
}
The exception:
Application error
Exception information:
Message: Couldn't find class Owners
Stack trace:
#0 /usr/share/php/Doctrine/lib/Doctrine/Table.php(256): Doctrine_Table->initDefinition()
#1 /usr/share/php/Doctrine/lib/Doctrine/Connection.php(1126): Doctrine_Table->__construct('Owners', Object(Doctrine_Connection_Mysql), true)
#2 /usr/share/php/Doctrine/lib/Doctrine/Query.php(1942): Doctrine_Connection->getTable('Owners')
#3 /usr/share/php/Doctrine/lib/Doctrine/Query.php(1740): Doctrine_Query->loadRoot('Owners', 'Owners')
#4 /usr/share/php/Doctrine/lib/Doctrine/Query/From.php(88): Doctrine_Query->load('Owners')
#5 /usr/share/php/Doctrine/lib/Doctrine/Query/Abstract.php(2077): Doctrine_Query_From->parse('Owners')
#6 /usr/share/php/Doctrine/lib/Doctrine/Query.php(1167): Doctrine_Query_Abstract->_processDqlQueryPart('from', Array)
#7 /usr/share/php/Doctrine/lib/Doctrine/Query.php(1133): Doctrine_Query->buildSqlQuery(true)
#8 /usr/share/php/Doctrine/lib/Doctrine/Query/Abstract.php(958): Doctrine_Query->getSqlQuery(Array)
#9 /usr/share/php/Doctrine/lib/Doctrine/Query/Abstract.php(1026): Doctrine_Query_Abstract->_execute(Array)
#10 /usr/share/php/Doctrine/lib/Doctrine/Query.php(267): Doctrine_Query_Abstract->execute(Array, 3)
#11 /var/www/twit/application/models/Owners.php(20): Doctrine_Query->fetchArray()
#12 /var/www/twit/application/controllers/AuthController.php(62): Twit_Model_Owners->checkUnique('a')
#13 /usr/share/php/libzend-framework-php/Zend/Controller/Action.php(516): AuthController->signupAction()
#14 /usr/share/php/libzend-framework-php/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('signupAction')
#15 /usr/share/php/libzend-framework-php/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#16 /usr/share/php/libzend-framework-php/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#17 /usr/share/php/libzend-framework-php/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#18 /var/www/twit/public/index.php(30): Zend_Application->run()
#19 {main}
Request Parameters:
array (
'module' => 'default',
'controller' => 'auth',
'action' => 'signup',
'username' => 'a',
'password' => 'x',
'confirmPassword' => 'x',
'captcha' =>
array (
'id' => 'ae5e3ce58bcf69e25ccdbba601029325',
'input' => 'hen753',
),
'register' => 'Sign up',
)
I can instantiate models without problem. This is the code i use to generate models:
Doctrine::generateModelsFromDb('/var/www/twit/application/models', array('zenddb'), array(
'baseClassesDirectory' => '',
'classPrefix' => 'Twit_Model_',
'classPrefixFiles' => false
));
Furthermore, if you want, you can visit the sample page here and get the error by yourself here.
http://94.94.19.135/twit/public/index.php/signup
It seems that Doctrine does not want the name of the table, as returned by $this->getTable()->getTableName()
but the name of the object (in my case Twit_Model_Owners)
personally I cannot understand such choice (to abstract is ok but at least the name of the tables in the query builder should be mantained), but I complain.

Categories