zend-framework2

ZF2 execute statement how to

元气小坏坏 提交于 2019-12-11 14:46:41
问题 I'd like to know what I'm doing wrong. This is my class. use Zend\Db\Adapter\Adapter; use Zend\Db\Sql\Sql; use Zend\Db\Sql\Select; class Country { protected $_dbA; protected $_sql; public function __construct(Adapter $dbA) { $this->_dbA = $dbA; $this->_sql = new Sql($this->_dbA); } public function getCity() { $select = new Select(); $sql = $select->from('es') ->columns(array('City')) ->where(array('ZIP' => 28934)); if (is_string($sql)) { $stm = $this->_dbA->createStatement($sql); } else {

ZEND - How to make it works on a shared host?

我们两清 提交于 2019-12-11 14:25:43
问题 I have to move a Zend website on a shared hosting which is using Pretty URL but css files doesn't load when params is added. Before moving, i want to test with server ip adress to be sure. For exemple -SERVER_IP/~username/en (works) -SERVER_IP/~username/en/news (fails because it search in "en" folder) I would like to redirect every css files from path /css/ to my real css folder which has many css files. I want same thing for every path /images/ and /js/ and maybe others. Can someone help me

Implementing ServiceLocatorAwareInterface dependency for forward() class in a ZF2 service

心已入冬 提交于 2019-12-11 14:22:56
问题 EDITED (Code is updated and working for others) For the overall idea of what's happening. I'm trying to access post data from the view in the controller, without refreshing the page. To do this I am executing the page controller by using a ViewHelper to call the Service below which then forwards back to the controller; afterwards I can manage the posted data in the page controller. Everything works except the last step which is the forward() , I receive the error Call to undefined method

How can i pass some data to a ValidationFilter? [Zend 2]

送分小仙女□ 提交于 2019-12-11 14:10:43
问题 I have got a ValidationFilter like Db_NoRecordExists in Zend 1. But in some cases it's okay that there is already a record with the same value - for example when i want to update some data. Maybe the username would be still the same after updating. But then my ValidationFilter gives an error. Now i could use something like "exclude ID XYZ". But how can i pass that IDs to the validationfilter? Thank You! 回答1: Use the setValidationGroup() method to tell your form which fields it should care

Zend Framework 2 - Doctrine 2 - Created at timestamp field

北慕城南 提交于 2019-12-11 14:02:19
问题 I want to create a custom created_at annotation in ZF2 . I found a (German) tutorial how to build such an annotation in Symfony2. Everything seems easy to copy except the registering of the prePersist listener. The code in Symfony is: services: created_at_listener: class: Scandio\Annotations\Driver\CreatedAtDriver tags: - {name: doctrine.event_listener, event: prePersist} arguments: [@annotation_reader] Any suggestions how to achieve this in Zend? Thanks! 回答1: Thanks to Ocramius I found a

How to give zend library path in our application? (In zend framework 2.3)

爱⌒轻易说出口 提交于 2019-12-11 13:45:13
问题 I have installed zend skeleton application in my local machine. I am working on ubuntu. I have installed it manually without using composer. I have given the ZF2_PATH(zend library path) in my httpd.conf. as in the below : <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/ SetEnv ZF2_PATH /var/www/lib/ZendFramework-2.3.1/library SetEnv APPLICATION_ENV "development" ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined It is working fine. I

How to set custom headers for individual controller actions in ZF2?

你说的曾经没有我的故事 提交于 2019-12-11 13:39:22
问题 I want to never the response of some of my controller actions in zend framework 2. This is the definitions of one my said controllers: 'login' => array( 'type' => 'segment', 'options' => array( 'route' => '/login[/:action][/:id]', 'constraints' => array( 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', 'id' => '[a-zA-Z0-9]*', ), 'defaults' => array( 'controller' => 'Presentation\Controller\Login', 'action' => 'index', ), ), ), I want none of the responses that this controller supplies to be cached. I

Zend Framework 2 - ZFCUser action whitelisting does not work for rerouting

夙愿已清 提交于 2019-12-11 13:14:28
问题 I'm using this function for whitelisting a few actions from the ZFCUser login. Everything works great unless I redirect to one of these whitelisted pages. For example I have the myFormAction which reroutes in case of an invalid form to itself or to a successAction . The problem is now that after clicking the button in any of these cases I end up seeing the ZFCUser login. When I go to one of these pages via URL or link there the first time, it works. Here is my code for the two cases in

How to put a character entity in the value of a formSubmit in ZF2

主宰稳场 提交于 2019-12-11 13:00:03
问题 When I create a submit button in a ZF2 form like this: $this->add(array( 'name' => 'save_closebutton', 'attributes' => array( 'type' => 'submit', 'value' => 'Save & Move On »', 'id' => 'save_closebutton', 'class' => 'btn btn-default' ), )); and then put a formSubmit element in the view like this: echo $this->formSubmit($form->get('save_closebutton')); ZF2 renders the text in the button as Save & Move On » without rendering the character that the code represents. I'm pretty sure that the

Ajax in Zend Framework2

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 12:57:35
问题 Hello People here is my code below, index.phtml code <div class="view clearfix" onClick="ajaxinfo()">Info</a></div> <script> function ajaxinfo(){ var id = 100; $.ajax({ type: "POST", url:"http://localhost/zf2/info/format/html", data:id, success:function(data){alert('ajax data success');}, error:function(){alert('ajax data failed to fetch');} }); return false; } </script> as you can see iam trying to pass id=100 to info.phtml page and try to get html data back from info.phtml lets assume info