I'm connecting to Redis Labs to use redis for our application.
Here is my configurations:
$conf=[
'scheme'=>'tcp',
'host'=>'ec2.cloud.redislabs.com',
'port'=>12860,
'database'=>'selector',
'password'=>'redispassword'
];
Then I do this to load the predis library:
require "lib/predis/autoload.php";
After which I do this:
$client = new Predis\Client($conf);
Then I try to run a command:
$client->hset('comments',"comment:1","{json_encoded_data}");
And this is the error I receive:
PHP Fatal error: Uncaught exception 'Predis\Connection\ConnectionException' with message '`SELECT` failed: ERR invalid DB index [tcp://cloud.redislabs.com:12860]' in /redis/lib/predis/src/Connection/AbstractConnection.php:155
I've looked online and people say I should set the database as 0 however If I do that how do I use my selected database?
Not sure what to do here.
The host parameter is for your instance endpoint:
And RedisLabs only allows one database per instance, so you'll have no problem using 0 in the database parameter:
That is exactly the reason why each of our Redis Cloud instances
allows using just one database (the default, 0-numbered database).
This ensures that any two databases in our service will never compete
on the resources of a single thread. In fact, trying to use any
database other than 0 with our service should produce an error.
Source
Related
I have a Symfony 3.4 application connected to an Oracle DB via a Wallet, so the configuration of the DB username and password are outside the app and of my control.
To let the application to work with this specific configuration I added in the config.yml, the parameter:
doctrine:
dbal:
connections:
default:
...
session_mode: !php/const OCI_CRED_EXT
...
The application works without any problem.
I have a sync function that connect to different DBs and sync some data.
The sync function can be run manually within the application UI and it works.
I wrote a console command to run in a cron job that instantiate the same set of classes used manually by the application but I got the error in object when I execute the command via terminal.
The exact error is:
In AbstractOracleDriver.php line 57:
An exception occurred in driver: ORA-12154: TNS:could not resolve the connect identifier specified
In OCI8Exception.php line 16:
ORA-12154: TNS:could not resolve the connect identifier specified
The same error occurs when testing the db connection with the console:
#php .\bin\console doctrine:query:sql "select sysdate,current_date from dual"
So, it seams that the console command in some way ignore that the oracle connection i made through a wallet and looks for servicename parameter which is, obviously, empty resulting in a TNS error.
Do someone have some suggestion on how to fix the issue?
Thanks,
Marco
I'm trying to build a script that imports items from a production database to a local one, but am having problems switching the connection form production to local.
Doctrine_Manager::getInstance()->setCurrentConnection('prod-slave');
// execute query to get data from production, confirm it worked
Doctrine_Manager::getInstance()->setCurrentConnection('local');
// insert data into local database
When I run this I'm getting this error:
PHP Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[HY000]:
General error: 1290 The MySQL server is running with the --read-only
option so it cannot execute this statement' in...
If I close the connection to prod-slave before setting it to local I get:
PHP Fatal error: Uncaught exception 'Doctrine_Manager_Exception' with message 'Unknown connection: prod-slave' in...
Notice that in both of these cases, it's still trying to connect to the slave even though I changed the connection to local (In the first case, it must be the slave since it is read-only).
I have also tried manually setting the connections with:
Doctrine_Manager::connection('mysql://path');
Doctrine version: 1.2.3
Symfony version: 1.3.9
Any help would be much appreciated.
Thank you
If you check generated base classes for your models, at the very beginning you will see each of your model is bound to specific connection. So even if you set current connection to another one, the one bound is used.
Solution is to call Doctrine_Manager::getInstance()->bindComponent($component, 'local'); for each of your models.
Instead of using setCurrentConnection try using getConnection
$slave = Doctrine_Manager::getInstance()->getConnection('prod-slave');
$result1 = $slave->execute($some_sql);
$local = Doctrine_Manager::getInstance()->getConnection('local');
$result2 = $local->execute($some_other_sql);
works for me on a symfony 1.4 project.
This should work providing that, in your config/databases.yml, you have the two connections prod-slave and local properly setup. And in your schema files you have bound your tables to the appropriate connections. (Just in case a doc on connections and all that can be found here )
I have used php5 to create a sqlite database. The database works fine when accessing its data using php.
However when I try and connect to the same sqlite file using firefox sqlite manager, I get the following error....
SQLiteManager: Error in opening file jTest.sqlite - either the file is
encrypted or corrupt Exception Name: NS_ERROR_FILE_CORRUPTED Exception
Message: Component returned failure code: 0x8052000b
(NS_ERROR_FILE_CORRUPTED) [mozIStorageService.openUnsharedDatabase]
My question:
Can you use php to create sqlite databases and have them work in other applications?
regards J
I have installed cassandra and apache Thrift. I have created a PHP test page to test it.When I am running it returning the following error.
Fatal error: Class 'CassandraClient' not found in /home/dev001/projects/Thrift/gen-php/cassandraTest.php on line 15
When I checked cassandra through the cassandra-cli, Its showing the following error.
power#power-desktop:/home/dev001$ cassandra-cli
org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused
at org.apache.thrift.transport.TSocket.open(TSocket.java:183)
at org.apache.thrift.transport.TFramedTransport.open(TFramedTransport.java:81)
at org.apache.cassandra.cli.CliMain.connect(CliMain.java:79)
at org.apache.cassandra.cli.CliMain.main(CliMain.java:255)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at org.apache.thrift.transport.TSocket.open(TSocket.java:178)
... 3 more
Exception connecting to 127.0.0.1/9160. Reason: Connection refused.
Welcome to Cassandra CLI version 1.1.0~rc1
Type 'help;' or '?' for help.
Type 'quit;' or 'exit;' to quit.
[default#unknown]
Please tell me why this happening ?
Seems that you don't have cassandra listening on the correct IP/port. Run a netstat -an to see if it is listening on port 9160.
Having said that:
Cassandra not working with php
Cassandra with PHP - on call of cassandra-test.php I get "Call to undefined method CassandraClient::batch_insert()"
In summary, the consensus among the masses is that you should avoid using raw thrift wherever possible and use one of the maintained client libraries: Which PHP client library to use with Cassandra?
in your terminal type:
# service cassandra start
before using cassandra.
This starts the cassandra deamon. which must be running before sending commands to cassandra
I was getting the same error
but when i started cassandra via cassandra_installation_dir/bin/cassandra and then "cassandra_installation_dir/bin/cassandra-cli --host 192.168.1.90" i was able to log in.
Try this way if that works.
I've got mongodb running in following configuration: 1 config server, 2 mongos, 8 shards (4 per mongos). I've got a problem using rockmongo administration tool:
if I connect to mongos router and try to list databases, I receive the following error:
Fatal error: Uncaught exception 'MongoCursorException' with message 'no primary!' in /home/vissi/var/www/rockmongo/app/models/MDb.php:5 ...
This problem exists only in one mongos, connecting to other mongos gives correct listing. Running db.serverStatus() in mongo console shows ... ok => 1 in both mongos.
if I connect to mongod running with shardsvr option, I see only config and local databases.
How should I connect to see all my databases correctly? phpmoadmin (and mongo console) runs show dbs ok.
If you have more than 1500 reputation, please, add rockmongo tag to this question.
The problem was resolved updating mongos at one of the machines from 1.6.5 to 1.7.3.