Skip to content
forked from alxmsl/Connection

Base classes for storage connections (redis, postgres) on PHP

License

Notifications You must be signed in to change notification settings

dec5e/Connection

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connection

Simple set of classes for support some connections. At this moment library supports:

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, 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);

License

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.

About

Base classes for storage connections (redis, postgres) on PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%