47 lines
845 B
PHP
47 lines
845 B
PHP
|
<?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);
|
||
|
}
|
||
|
|
||
|
}
|