zend-framework2

Zend Framework 2 and SELECT count(*) query

我只是一个虾纸丫 提交于 2019-12-04 02:19:05
I'm trying to do a query like this using Zend Framework 2: SELECT count(*) as num FROM mytable Here's the code I'm using to build my select statement (bear in mind I've imported the necessary classes): $select = new Select(); $select->from('mytable') ->columns(array('num'=>'count(*)'), false); This code doesn't work because the resulting query is as follows: SELECT [count(*)] AS [num] FROM [mytable] ...which throws the following error: Invalid column name 'count(*)' This is caused by the square brackets around count(*). How can I get this to work properly, basically to have count(*) instead of

PHP retrieving array values using dash arrow “->”

╄→尐↘猪︶ㄣ 提交于 2019-12-03 22:31:47
I've been using PHP quite a while now, but never been an advanced programmer. I feel like this is dumb question but never understood why some array values can be retrieved using different methods: This: $array->value rather than normal: $array['value'] The standard $array['value'] always works, but the one using the -> method doesn't at times. Why is that? Here's an example. I am using Zend Framework 2 and I can grab a session value using the -> method: $this->session->some_value However, I can't if I do a new, normal array: $array = array('some_value' => 'myvalue'); $array['some_value']; //

CodeIgniter 2 + Zend 2 library barcode

点点圈 提交于 2019-12-03 21:26:35
Problem: rendering barcodes in CodeIgniter via Zend library barcode. I googled, and also tried all tutorials on first 2 pages. I stackoverflowed and found quiet a few topics on my problem, even few are marked as answered but no luck. Finally I tried this https://stackoverflow.com/a/15480779/1564365 but yet another error message. error: Fatal error: Class 'Zend\Barcode\ObjectPluginManager' not found that means it is actually loading Barcode library but with error. sidenote : ZF 2.2 fresh download (today), CI 2.1.3 fresh download (today) To solve this, I am forced to use ZF1. step by step:

how to use ajax in zend framework 2 or the AjaxContext?

女生的网名这么多〃 提交于 2019-12-03 21:25:15
AjaxContext helper was a neat feature in ZF1 and i used it in many places. I was wondering if this is available in ZF2. I did a test and added: public function init() { $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('input', 'html') ->addActionContext('number', 'html') ->initContext(); } in the controller, added a action: public function inputAction() { $form = new AddInput(); return ['form' => $form]; } a file input.ajax.phtml and a ajax call: $.get('/form/input/format/html').css("display","block"); The request goes through ok, with a 200 code, but i

How to remove a validator from a Form Element / Form Element ValidatorChain in Zend Framework 2?

99封情书 提交于 2019-12-03 21:18:10
问题 I read this question on SO: "how to disable inArray validator forms in zend framework2" and was trying to find it out, but couldn't find any way to detach/remove the InArray Validator. But InArray is just a validator. So how can remove a validator from the validator list of a form element? I can get the validators: $myElement = $form->getInputFilter()->get('city'); $validatorChain = $cityElement->getValidatorChain(); $validators = $validatorChain->getValidators(); and maybe can then unset the

Publishing assets from modules in Zend Framework 2

喜欢而已 提交于 2019-12-03 21:14:12
It is generally adviced to store module assets inside the module's directory, inside moduleName/public (or whatever you want to name the asset's directory). Zend Framework 2 unfortunately doesn't support asset publishing for module assets by default. According to MWOP , there was nothing planned ~1 month ago and I guess there still is no real plan (they had probably a lot of work to get the stable version ready). (But, some day, they are going to address this issue.) As my ZF2 app is growing and growing, I reached the point where I need to have module-specific assets . At the moment, I

Zend Framework 2 display a view within a view

一个人想着一个人 提交于 2019-12-03 20:21:47
I have two modules Admin and Login. I want to display the Login view 'login.phtml' within the admin view 'index.html' I have the following in the Admin modules indexAction controller public function indexAction() { $login = new LoginController(); $view = new ViewModel(array( 'theloginform' => $login->loginAction(), )); return $view; } In the LoginAction method in the Login controller I return the ViewModel for the 'login.phtml' file. public function LoginAction() { $view = new ViewModel(); return $view; } The indexAction throws an error as the variable 'theloginform' is an object. Catchable

ZF2/Doctrine2 - Fieldsets not validated, data is always valid

强颜欢笑 提交于 2019-12-03 18:15:31
问题 I've set up a structure using Abstract classes for Forms, Fieldsets and InputFilters. Forms and Fieldsets have Factories while InputFilters are created and set on the Fieldsets by the FieldsetFactory (uses the MutableCreationOptionsInterface to pass along options) The problem I have is that InputFilters are loaded for the Form, but are not used to validate the data. All input is accepted as valid. E.g. I have a Country Entity with a name property. The name of the Country must be at least 3

How to use the cache in doctrine 2 and zend framework 2?

我的梦境 提交于 2019-12-03 17:34:33
plz i need some help here , i've goolged a lot but without result :/ how can i exploit the query and their result stored in the memcache , i'm working with zend framework 2 and doctrine 2 ? and here is my configuration in module.config.php : // Doctrine config 'doctrine' => array( 'driver' => array( __NAMESPACE__ . '_driver' => array( 'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', 'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity') ), 'orm_default' => array( 'drivers' => array( __NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver' ), ) ), /***** enabling the

Set Different Layout for Different Module in Zend Framework 2?

这一生的挚爱 提交于 2019-12-03 17:23:58
I have two module Student and Teacher. I also have two different layout one is studentlayout.phtml and another is teacherlayout.phtml How can I set studentlayout for Student module and teacherlayout for Teachermodule? As Per Sam's answer .Thanks Its working fine. but i also want to set two different layout For Teacher. So i add following code in my main config file for project: 'module_layouts' => array( 'Teacher' => array( 'default' => 'layout/adminlayout', 'login' => 'layout/loginlayout', ), 'Student' => 'layout/studentlayout', ), My module.config.php file for teacher module: 'module_layouts