It is not a good practice to run a query directly inside your class. I recommend you to fit your query in the model and create a mapper which can execute it. Then setup your mapper to be injected in your class, where you require it. If you need any more details please ask.
poashoas wrote > > I just want to run a simple query inside my class. > Lets say something like: > > $query = "SELECT blah FROM test WHERE 1=1"; > $result = execute($query); > > class PermissionsAcl extends AbstractPlugin { > protected $sesscontainer ; > > private function getSessContainer() > { > if (!$this->sesscontainer) { > $this->sesscontainer = new SessionContainer('zftutorial'); > } > return $this->sesscontainer; > } > > public function doAuthorization($e) > { > $Listacl = new Whitelist(); > $test = $Listacl->getWhitelist(); > $cache = StorageFactory::factory(array( > 'adapter' => array( > 'name' => 'Filesystem', > 'options' => array( > 'cacheDir' => 'data/cache',//__DIR__ . > '/../../../../../../ > ), > ), > 'plugins' => array('serializer'), > )); > $cache->setItem('testing-array', array('hello' => 'test')); > $array = $cache->getItem('testing-array'); > print_r($array); > //setting ACL... > $acl = new Acl(); > //add role .. > $acl->addRole(new Role('anonymous')); > $acl->addRole(new Role('user'), 'anonymous'); > $acl->addRole(new Role('admin'), 'user'); > > $acl->addResource(new Resource('Application')); > // $acl->addResource(new Resource('Login')); > > $acl->allow('anonymous', 'Application', 'view'); > // $acl->allow('anonymous', 'Login', 'view'); > > $acl->allow('anonymous', > array('Application'), > array('view') > ); > > $routeMatch = $e->getRouteMatch(); > $namespaceController = $routeMatch->getParam('controller'); > $namespace = str_replace('\Controller\\' . > ucfirst($routeMatch->getParam('action')),'',$namespaceController); > > $role = (! $this->getSessContainer()->role ) ? 'anonymous' : > $this->getSessContainer()->role; > if ( ! $acl->isAllowed($role, $namespace, 'view')){ > $router = $e->getRouter(); > //$url = $router->assemble(array(), array('name' => > 'Login/auth')); > > $response = $e->getResponse(); > $response->setStatusCode(302); > //redirect to login route... > // $response->getHeaders()->addHeaderLine('Location', $url); > } > } > } > ----- Cheers, -- Luke Mierzwa -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/ZF2-query-something-tp4656840p4656865.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com