add user/group ser
This commit is contained in:
parent
8214e0ce8d
commit
9bc2e4e065
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Li Jianxuan
|
||||
* Date: 14-9-19
|
||||
* Time: 下午3:21
|
||||
*/
|
||||
|
||||
namespace Westdc\User;
|
||||
|
||||
use Zend\ServiceManager\ServiceManager;
|
||||
use Zend\ServiceManager\ServiceManagerAwareInterface;
|
||||
|
||||
class Group implements ServiceManagerAwareInterface{
|
||||
|
||||
protected $serviceManager;
|
||||
|
||||
private $db;
|
||||
|
||||
public function setServiceManager(ServiceManager $serviceManager)
|
||||
{
|
||||
$this->serviceManager = $serviceManager;
|
||||
|
||||
$this->init();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function init()
|
||||
{
|
||||
$dbService = $this->serviceManager->get('Db');
|
||||
$this->db = $dbService->getPdo();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function fetchAll () {
|
||||
|
||||
$sql = "SELECT * FROM groups";
|
||||
$rs = $this->db->query($sql);
|
||||
|
||||
return $rs->fetchAll(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue