can't make code generator with PostgreSQL - postgresql

i have a problem in using code generator with PostgreSQL database, i've make configuration in main.php..
...
'modules'=>array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'123wasis85',
'ipFilters'=>array('127.0.0.1','::1'),
),
),
...
'db'=>array(
'connectionString' => 'pgsql:host=127.0.0.1;port=5432;dbname=yii_first',
'emulatePrepare' => true,
'username' => 'postgres',
'password' => 'anghauz',
'charset' => 'utf8',
),
...
but it still making error result when i used crud generation, this is the error..:
...
CDbConnection failed to open the DB connection: could not find driver
C:\BitNami\apache2\htdocs\yii\framework\gii\generators\crud\CrudCode.php(44)
...
i make it in localhost n using bitnami..
please help me guys for the solutions..

Please go to php.ini file in the installed php folder. Uncomment the below lines.
extension=php_pdo_pgsql.dll
extension=php_pgsql.dll
It worked for me.

Related

PHP Warning in Typo3DatabaseBackend line 158 after updating DDEV to 1.19

After updating DDEV to 1.19 I get following error after backend login in TYPO3 11.5.8:
PHP Warning: gzuncompress(): need dictionary in
/var/www/html/public/typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php
line 158
I already tried a lot of things:
I have tried all officially PHP versions which are possible with DDEV.
I have downgraded doctrine/dbal 2.13.8, 2.13.7, 2.13.6, ...
I have downgraded MariaDB 10.3 to 10.2
Nothing works. So it needs a deeper view of the problem:
In Typo3DatabaseBackend.php at line 158 I have added
$tmp = gzuncompress($data);
With help of xdebug I can see that uncompress works without any problems. So, IMO it can't be a zlib problem.
As next step I have converted the compressed $data with bin2hex($data) into $tmp and in my database I have tried to HEX the value, too:
SELECT uid, CONVERT(content USING utf8) FROM cache_rootline WHERE uid = 1;
Interesting point:
Before: 789c4d904172c3200
In DB: 0x783f4d3f41723f200
Select: 783f4d3f41723f200
Nearly each 2nd byte is correct, but the other bytes are totally wrong.
I have exported my MariaDB data and switched to MySQL 8.0 and imported the data again. Because of some utf8mb4_unicode_ci incompatibilities I have recreated all cache tables with help of Installtool of TYPO3.
After login to TYPO3 backend I got following error:
General error: 3988 Conversion from collation utf8_general_ci into utf8mb4_unicode_ci impossible
I have searched full TYPO3 project, but I can't find utf8_general_ci anywhere.
Do you have any idea, what could be wrong?
Thank you for your help.
Stefan
On new DDEV project four LocalConfiguration looks something like that:
'DB' => [
'Connections' => [
'Default' => [
'charset' => 'utf8',
'driver' => 'mysqli',
],
],
],
and DDEV creates following to your AdditionalConfiguration.php
'DB' => [
'Connections' => [
'Default' => [
'dbname' => 'db',
'driver' => 'pdo_mysql',
'host' => 'db',
'password' => 'db',
'port' => '3306',
'user' => 'db',
],
],
],
Maybe you have added following to your configuration to create new tables with a specific collation:
'DB' => [
'Connections' => [
'Default' => [
...
'tableoptions' => [
'charset' => 'utf8mb4',
'collate' => 'utf8mb4_general_ci',
],
],
],
],
Do you see the problem? The charset option of LocalConfiguration.php was NOT overwritten in your AdditionalConfiguration. So, you have a charset miss-match in your configuration. Please keep them in sync.
Either set collation back to utf8_unicode_ci or add:
'charset' => 'utf8mb4',
in AdditionalConfiguration.php
Have fun with TYPO3
Stefan
For me the easiest way was to replace the pdo_mysql driver with mysqli.
Because I'm only using MariaDB and my database was utf8_general_ci encoded, this was the easiest fix/help.

MongoDB with Laravel 8 Authentication Failed upon php artisan migrate

I Installed mongoDB in my laravel 8 project for first time, to explore mongoDB functionalities
When I run php artisan migrate I got:
MongoDB\Driver\Exception\AuthenticationException
Authentication failed.
at D:\xampp\htdocs\Mongo\mongonews\vendor\mongodb\mongodb\src\Command\ListCollections.php:115
my : D:\xampp\htdocs\Mongo\mongonews\config\database.php I set the following:
'mongodb' => [
'driver' => 'mongodb',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'options' => [
// here you can pass more settings to the Mongo Driver Manager
// see https://www.php.net/manual/en/mongodb-driver-manager.construct.php under "Uri Options" for a list of complete parameters that you can use
'database' => env('DB_AUTHENTICATION_DATABASE', 'admin'), // required with Mongo 3+
],
],
And this is my .env:
DB_HOST=127.0.0.1
DB_PORT=27017
DB_DATABASE=mongonews
DB_USERNAME=root
DB_PASSWORD=
Thanks Geaks, appreciate your help to start my first time mongo db based laravel app
All the best.
It was solved by removing username from DB_USERNAME
although It is supposed to be "root" in my case!!!!
DB_CONNECTION=mongodb
DB_HOST=127.0.0.1
DB_PORT=27017
DB_DATABASE=news
DB_USERNAME=
DB_PASSWORD=
Hope this helps who ever faced this problem.

MongoDB Connect Issue jenssegers/laravel-mongodb

I'm using jenssegers/laravel-mongodb MongoDB Jenssegers
I'm running into an issue where I can't seem to connect using the framework, but using a simple test script, I can connect fine.
The simple connection script I wrote:
<?php
$manager = new MongoDB\Driver\Manager("mongodb://user:password#cluster0-shard-00-00-reodz.mongodb.net:27017,cluster0-shard-00-01-reodz.mongodb.net:27017,cluster0-shard-00-02-reodz.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin");//ssl=true
$command = new \MongoDB\Driver\Command(["ping" => 1]);
$cursor = $manager->executeCommand("admin", $command);
$reply = $cursor->toArray()[0];
var_dump($reply);
When I run that, I get
["ok"]=> int(1)
Which is what I expect and is all good. I setup my config/database.php file with the same connection string, this is my config/database.php file:
return [
'default' => env('DB_CONNECTION','mongodb'),
'connections' => [
'mongodb' => [
'driver' => 'mongodb',
'dsn' => env('DB_DSN','mongodb://user:password#cluster0-shard-00-00-reodz.mongodb.net:27017,cluster0-shard-00-01-reodz.mongodb.net:27017,cluster0-shard-00-02-reodz.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin'),
'database' => env('DB_DATABASE'),
]
]
];
The .env file:
APP_ENV=local
APP_DEBUG=true
APP_KEY=
APP_TIMEZONE=UTC
#DB_CONNECTION=mongodb
#DB_HOST="cluster0-shard-00-00-reodz.mongodb.net"
#DB_PORT=27017
DB_DATABASE="test"
#DB_USERNAME="user"
#DB_PASSWORD="password"
CACHE_DRIVER=file
QUEUE_DRIVER=sync
When I access a route that I've associated with MongoDB, I'm getting:
(1/1) ConnectionTimeoutException
No suitable servers found (serverSelectionTryOnce set): [Failed to resolve 'user:password#cluster0-shard-00-00-reodz.mongodb.net:27017,cluster0-shard-00-01-reodz.mongodb.net:27017,cluster0-shard-00-02-reodz.mongodb.net:27017/test?ssl=true&replicaset=cluster0-shard-0&authsource=admin']
I would assume the problem is localized to my database.php file or my .env file, does anyone see an error? If the test.php can connect and return the ping, shouldn't Lumen be good to go?
Thanks
D

ZfcUserDoctrineMongoODM Configuration examples

I am trying to configure ZendFramwork 2 to use MongoDB as the storage for user Authentication.
I already have installed what I believe are the correct modules and have a correctly installed instance of ZF2 running on Nginx. I also have an instance of Mongo running and I am already using this for another project. The modules declaration in application.config.php looks like this
'modules' => array(
'Application',
'ZfcBase',
'ZfcUser',
'ZfcUserDoctrineMongoODM',
'DoctrineModule',
'DoctrineMongoODMModule'
)
Documentation is a bit thin on how to configure the system to get it working. Can anyone provide any code fragments around configuring the database settings to allow Mongo to run with ZfcUser, this is where I am at a loss now.
Any help, clues or cheat sheets would be greatly appreciated.
Darren Breeze
Have a look at Doctrine Mongo ODM module readme https://github.com/doctrine/DoctrineMongoODMModule :
copy
vendor/doctrine/doctrine-mongo-odm-module/config/module.doctrine-mongo-odm.local.php.dist
into your application's config/autoload directory, rename it to
module.doctrine-mongo-odm.local.php and make the appropriate changes.
With this config file you can configure your mongo connection, add
extra annotations to register, add subscribers to the event manager,
add filters to the filter collection, and drivers to the driver chain.
So you have something like this at your autoload config:
<?php
return array(
'doctrine' => array(
'connection' => array(
'odm_default' => array(
'server' => 'localhost',
'port' => '27017',
// 'connectionString' => null,
// 'user' => null,
// 'password' => null,
// 'dbname' => null,
// 'options' => array()
),
),
....
'configuration' => array(
'odm_default' => array(
... 'default_db' => 'myappdb',
)
)
So tune it and try to register at user/register. Collection name is user by default.

zend framework 2 Authentication with mysqli fail

I have followed the zend instructions for implement my web Authentication using a database table with Mysqli driver configured.
When render the page, the following exceptions appears after execute authenticate method:
Zend\Db\Adapter\Exception\ErrorException
File:
C:\xampp\htdocs\pfc\vendor\ZF2\library\Zend\Db\Adapter\Driver\Mysqli\Statement.php:188
Mensaje:
Commands out of sync; you can't run this command now
It seems to be that it happen because the driver don't can execute multiples querys without free the results of the previous query first (multiquery problem).
I discovered that if changed the driver of the dbAdapter to pdo_mysql, authenticate method works ok. But I don't want use PDO drivers by performance reasons.
How I configure the Mysqli driver for can do it?
My code bellow:
$dbAdapter = new DbAdapter(array(
//'driver' => 'Mysqli', //This driver fail when call authenticate method
'driver' => 'Pdo_Mysql', //This driver works ok
'database' => 'securedraw',
'username' => 'root',
'password' => ''
));
$authAdapter = new AuthDbTableAdapter($dbAdapter);
$authAdapter->setTableName('users')
->setIdentityColumn('mail')
->setCredentialColumn('password')
->setIdentity('josep')
->setCredential('josep');
$authResult = $authAdapter->authenticate(); //Method fail
I am pretty sure what the problem is is that you are mixing up the ways execute the query. So what you have is for a PDO call and to use MySQLi you need to do
$dbAdapter = new DbAdapter(array(
'driver' => 'Mysqli', //This driver fail when call authenticate method
'database' => 'securedraw',
'username' => 'root',
'password' => ''
));
$adapter = new Zend\Db\Adapter\Adapter($configArray);
$adapter->query("QUERY HERE");
I would reference this page here https://packages.zendframework.com/docs/latest/manual/en/modules/zend.db.adapter.html as I am trying to learn how to do this myself