Configuration of Yii2 oci8 module - php

i am trying to connect my Yii2 project to Oracle db, i have found this oci8 plugin for yii2 written by apaoww on github. I managed to get php oci8 extension working, and encountered i hope my last problem with the connection.
I know dbname, ip, username, password and port to connect on, but still i was not able to decrypt, where the schemaname belongs to, i probably am a complete dumba**, but i was not able to find any other examples of filling the dp.php config file, than the one on GitHub project page, which didn't really make it clear for me. My issue is, where should i put the schemaname in this array?
'db' => [
'class' => 'apaoww\oci8\Oci8DbConnection',
'dsn' => 'oci8:dbname=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SID=xe)));charset=AL32UTF8;',
'username' => 'yourdatabaseschemaname',
'password' => 'databasepassword',
'attributes' => []
],

Related

Typo3 with MSSQL [duplicate]

I tried to install TYPO3 (8.7.7) on my Webserver (IIS) and I'd like to use my SQL Server instead of MySQL.
I found lots of instructions how to make this (on typo3.org and other websites) but none of these worked for me.
I found out, that I must install two extensions before I start the installation (ADOdb & DBAL). Probably there is my fault.
Can anybody explain step by step how to install these extensions before the TYPO3 installation?
I'm using the following configuration to successfully run TYPO3 on SQL Server on my local windows machine:
'DB' => [
'Connections' => [
'Default' => [
'charset' => 'utf-8',
'dbname' => 't3',
'driver' => 'sqlsrv',
'host' => 'localhost',
'password' => 'yourPassword',
'port' => 1433,
'user' => 'sa',
],
],
],
It's a bit complicated to set up with the installer as it is not yet "clickable". What you can do is call the install script and when it's asking you to configure the database connection you go to your file system and manually add the config section above (with your connection params of course) in the LocalConfiguration.php file.
Then reload the installer - which should now recognize the configured database connection and let you go to the last step where you can import / create the base tables and data.
Note: At the moment I know of two bigger areas where SQL Server is still a problem with TYPO3 8.7 - that's workspaces and database compare. The last one means that after you have existing data in your SQL Server tables won't let you alter them via the TYPO3 database compare tool - you have to change tables manually if you need to.
Find a gist of the table create statements on https://gist.github.com/psychomieze/9570ea1f578aee7a1fbb68c3240a21c8
With 8.7, Doctrine DBAL has been integrated into the core and ADOdb & DBAL sysexts have been removed as there is no need anymore.
Take a look at the documentation of Doctrine DBAL http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html and it should fit perfectly to the configuration of the DB in `LocalConfiguration.php``
'DB' => [
'Connections' => [
'Default' => [
'charset' => 'utf8',
'dbname' => 'typo3',
'driver' => 'mysqli',
'host' => 'mysql',
'password' => 'dev',
'port' => 3306,
'user' => 'root',
],
],
],
Now my Typo3 is working.
I solved my problem a little bit complicated.
I made a test environment and installed Typo3 with MySQL.
Then I copied the database with the "Microsoft SQL Server Migration Assistant 7.6 for MySQL"
(https://www.microsoft.com/en-us/download/details.aspx?id=54257) to my main environment.
After that I copied all the created folders (typo3conf, typo3temp etc.) to my main environment
and edited the databaseconnection in the LocalConfiguration.php file like Georg Ringer proposed.
When I am installing Typo3 and MSSQL next time I will do it like susi proposed.
Thanks for your help.

SSL Yii connection to postgresql Google cloud database

I’m newbie user of Yii and I need to connect my Yii2 application to a Google cloud database (postgres). I need to made the connection using the SSL certificates I already have. I have all the credentials (host, user, 3x ssl, etc).
The thing is I’m able to connect to this remote google database using both PgAdmin client and the Google SDK console (Google Shell), but I can’t connect my Yii2 application to this database. I read a lot of documentation and found nothing.
This is what I have in my common/config/main-local.php (Yii2 advanced configuration), I added the field 'attributes', just in case it works, but as I thought is not working:
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'pgsql:host=my-host;dbname=my-db-name',
'attributes' => [
PDO::PGSQL_ATTR_SSL_KEY => 'path/to/my/client-key.pem',
PDO::PGSQL_ATTR_SSL_CERT => 'path/to/my/client-cert.pem',
PDO::PGSQL_ATTR_SSL_CA => 'path/to/my/server-ca.pem',
],
'username' => 'myusername',
'password' => 'mypassword',
'charset' => 'utf8',
],
This is how I connect through Google Shell, this works:
psql "sslmode=verify-ca sslrootcert=path/to/my/server-ca.pem sslcert=path/to/my/client-cert.pem sslkey=path/to/my/client-key.pem hostaddr=google-instance-host user=david.tamarit dbname=google-db-name"`
Then, I put my password and I'm connected to my database in Google shell.
In PgAdmin, I pass my credentials and I connect to the database, this works too.
How can I connect to my google cloud database using Yii?
Thanks in advance!
Since the DB is not on your machine there is no need for you to have PostgreSQL installed and this is the reason (I think) that these constants are not recognised. Try this:
'attributes' => [
'sslmode' => 'verify-ca',
'sslkey' => 'path/to/my/client-key.pem',
'sslcert' => 'path/to/my/client-cert.pem',
'sslrootcert' => 'path/to/my/server-ca.pem',
],

Drupal 8 Local Set Up

I am trying to import a Drupal 8 site from a git repository.
I am using Acquia Dev Desktop 2 to set it up.
But, I always get this error:
Do you know what is causing this error?
Any suggestions are greatly appreciated.
Likely your local site's database connection does not have the same settings as the one you're cloning. DevDesktop tries to access the database with with drupaluser as the username and no password.
Unless you're using Acquia Cloud and can sync your DB using DevDesktop, I would recommend exporting your remote db from the site you're cloning. Then create a new database in DevDesktop and either import the database using rsync or phpmyadmin, or instruct DD to import it from the dump file.
Then you have to tell Drupal to pick up the new database with the new credentials, so your local settings.php must contain your local database info:
$databases['default']['default'] = array(
'driver' => 'mysql',
'database' => '<yourDatabaseNameHere>',
'username' => 'drupaluser',
'password' => '',
'host' => '127.0.0.1',
'port' => 33067,
);

Can't connect to database with laravel 5

I'm trying to connect to my mssql database with laravel 5 but it's not working. I've tried to connect with different mssql databases so it's not a firewall issue. Also my credentials are correct. I found on google that you need SQL Server Native Client 11.0 and I've already installed that.
This is my connection array in config/database.php:
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('nvt'),
'database' => env('nvt'),
'username' => env('nvt'),
'password' => env('nvt'),
'charset' => 'utf8',
'prefix' => '',
],
And I've set the default to "sqlsrv" :
'default' => env('sqlsrv','sqlsrv'),
But when I'm trying to create a table I receive the error:
PDOException in Connector.php line 50: could not find driver
What could be wrong???
EDIT:
I've installed pdo for sqlsrv from here:
http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx
And I added it to my php.ini file:
extension=\Installaties\php_pdo_sqlsrv_53_nts.dll
But stil I receive the error?
Try to remove the eve() method, i mean use the following method
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => 'nvt',
'database' => 'nvt',
'username' => 'nvt',
'password' => 'nvt',
'charset' => 'utf8',
'prefix' => '',
],
I ran into a similar issue. Try putting in the server info directly rather than using env. If it works, then you know Laravel is having an issue reading the .env file.
I encountered your problem the last time I tried my connection in sqlsrv. I am using xampp. Try putting yung php_pdo_sqlsrv_53_nts.dll in the ext folder, replace extension=\Installaties\php_pdo_sqlsrv_53_nts.dll with extension=php_pdo_sqlsrv_53_nts.dll and try installing odbc 11 on your computer. It worked for me but not sure why. (not an expert) if it worked good to help a fellow person and if not, sorry for the trouble. Thank you for the time reading.
You may try any of the following solutions
Check that you have entered the right connection parameters. Test by connecting to the DB with a client tool.
Make sure you have the right version of sqlsrv configured for your machine. Check the PHP logs to be sure your web server was able to load the extension correctly.
Set the port to null in your env file
As a tip, I won't advise anyone to set the connection parameters anywhere but in the .env (Setting it in config/database is a security risk).

Yii Framework with CPanel: Database error when trying to access 'model' generator in gii

I got this error when trying to access 'model' and 'CRUD' generator in gii.
CDbConnection failed to open the DB connection: SQLSTATE[42000] [1044]
Access denied for user 'jivaindo_fin'#'localhost' to database
'jivaindo_finale'
The server is remote in other place. And using Cpanel to access it. the server name is 'jivcom.com'.
(i edited the file using filezilla)
The database used is MySQL.
I have checked database name, database username and password. And all is match in the Cpanel.
This is the config/main.php in the web folder. i suspect this is where i get the error but i can't find it.
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=jivaindo_finale',
'emulatePrepare' => true,
'username' => 'jivaindo_fin',
'password' => 'j1v41nd0',
'charset' => 'utf8',
),
Can anybody help me for this problem? any solution to make it able to access the 'model' generator?
Have you tried 127.0.0.1 instead of localhost in your connectionString?

Categories