2015-01-26 18:28:39 +00:00
|
|
|
<?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;
|
|
|
|
|
2015-01-26 18:42:06 +00:00
|
|
|
class Group implements ServiceManagerAwareInterface {
|
2015-01-26 18:28:39 +00:00
|
|
|
|
2015-01-26 18:42:06 +00:00
|
|
|
protected $serviceManager;
|
2015-01-26 18:28:39 +00:00
|
|
|
|
2015-01-26 18:42:06 +00:00
|
|
|
private $db;
|
2015-01-26 18:28:39 +00:00
|
|
|
|
2015-01-26 18:42:06 +00:00
|
|
|
public function setServiceManager (ServiceManager $serviceManager) {
|
|
|
|
$this->serviceManager = $serviceManager;
|
2015-01-26 18:28:39 +00:00
|
|
|
|
2015-01-26 18:42:06 +00:00
|
|
|
$this->init();
|
2015-01-26 18:28:39 +00:00
|
|
|
|
2015-01-26 18:42:06 +00:00
|
|
|
return $this;
|
|
|
|
}
|
2015-01-26 18:28:39 +00:00
|
|
|
|
2015-01-26 18:42:06 +00:00
|
|
|
private function init () {
|
|
|
|
$dbService = $this->serviceManager->get('Db');
|
|
|
|
$this->db = $dbService->getPdo();
|
|
|
|
}
|
2015-01-26 18:28:39 +00:00
|
|
|
|
|
|
|
|
2015-01-26 18:42:06 +00:00
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function fetchAll () {
|
2015-01-26 18:28:39 +00:00
|
|
|
|
2015-01-26 18:42:06 +00:00
|
|
|
$sql = "SELECT * FROM groups";
|
|
|
|
$rs = $this->db->query($sql);
|
2015-01-26 18:28:39 +00:00
|
|
|
|
2015-01-26 18:42:06 +00:00
|
|
|
return $rs->fetchAll(\PDO::FETCH_ASSOC);
|
|
|
|
}
|
2015-01-26 18:28:39 +00:00
|
|
|
|
|
|
|
}
|