Simple set of classes for support some connections. At this moment library supports:
- redis connection over phpredis
- redis connection over predis
- postgresql connection
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'));
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'));
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, false);
$Data = $Result->getResult();
var_dump($Data[0]);
// ..query data with parameters
$Result = $Connection->query('select count(*) from {{ tbl(table) }}', array(
'table' => 'pg_class',
), false);
$Data = $Result->getResult();
var_dump($Data);
Copyright © 2014 Alexey Maslov [email protected] This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details.