alxmsl / connection
Simple library for support storage connections
Requires
- predis/predis: 1.0.*
Requires (Dev)
- phpunit/phpunit: 4.4.*
README
Simple set of classes for support some connections. At this moment library supports:
- redis connection over phpredis
- redis connection over predis
- postgresql connection
Predis usage example
use alxmsl\Connection\Predis\PredisFactory;
// Create Redis Client instance with you configuration settings
$Redis = PredisFactory::createPredisByConfig(array(
'host' => 'localhost',
'port' => 6379,
));
// Use Redis commands
$Redis->set('test', '7');
var_dump($Redis->get('test'));
Redis usage example (phpredis)
use alxmsl\Connection\Redis\RedisFactory;
// Create Redis Client instance with you configuration settings
$Redis = RedisFactory::createRedisByConfig(array(
'host' => 'localhost',
'port' => 6379,
));
// Use Redis commands
$Redis->set('test', '7');
var_dump($Redis->get('test'));
Postgres usage example
use alxmsl\Connection\Postgresql\Connection;
// Create connection
$Connection = new Connection();
$Connection->setUserName('postgres')
->setPassword('postgres')
->setDatabase('postgres')
->setHost('localhost')
->setPort(5432);
// Connect and ...
$Connection->connect();
// ..query needed data
$Result = $Connection->query('select * from "pg_class"', null);
$Data = $Result->getResult();
var_dump($Data[0]);
// ..query data with parameters
$Result = $Connection->query('select count(*) from {{ tbl(table) }}', array(
'table' => 'pg_class',
));
$Data = $Result->getResult();
var_dump($Data);
Contributing
I welcome any help in developing this project. I accept contributions as pull requests. Finally, I kindly ask that you add your tests and document all changes in library behavior/corrections. You are welcome to add copyright notices with your name/nickname and email in all files, that you change
License
Copyright 2015-2016 Alexey Maslov alexey.y.maslov@gmail.com
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.