zend-framework2

Extending ZfcUser with Zend Framework 2

走远了吗. 提交于 2019-12-06 00:46:27
问题 Hi I am trying to write a user registration form using ZfcUser module for Zend Framwork 2 and would like some advice on best practices when adding more user fields. So far I have created my own module called "WbxUser" and as outlined in the modules wiki pages I have added a custom field called "userlastname" to ZfcUser's registration form by using the Event Manager in my modules bootstrap function like so. Code: //WbxUser.Module.php namespace WbxUser; use Zend\Mvc\MvcEvent; class Module {

Inserting NULL into NOT NULL columns with Default Value

时间秒杀一切 提交于 2019-12-06 00:40:45
问题 For a bit of background, we use Zend Framework 2 and Doctrine at work. Doctrine will always insert NULL for values we do not populate ourselves. Usually this is okay as if the field has a default value, then it SHOULD populate the field with this default value. For one of our servers running MySQL 5.6.16 a query such as the one below runs and executes fine. Although NULL is being inserted into a field which is not nullable, MySQL populates the field with its default value on insert. On

How to handle multidimensional output with (nested) lists using the Zend\\Db\\TableGateway with a mapper in Zend Framework 2?

烈酒焚心 提交于 2019-12-05 22:53:46
I'm developing a RESTful ZF2 based application and using a TableGateway implementation (subclass of the Zend\Db\TableGateway ) in combination with a simple mapper for the model, similar to the Album example of the ZF2 manual . Table class <?php namespace Courses\Model; use ... class CourseTable { protected $tableGateway; public function __construct(TableGateway $tableGateway) { $this->tableGateway = $tableGateway; } public function findOnceByID($id) { $select = new Select(); $where = new Where(); $select->columns(array( 'id', 'title', 'details', )); $select->from($this->tableGateway->getTable(

using Zend_Db zf2 module outside of zf2 mvc

徘徊边缘 提交于 2019-12-05 22:29:50
I'm writing a PHP application that is not based on zf2 mvc. I do want to use only the Zend_Db zf2 module. how can I configure my application to know how to find the Zend_Db releveant PHP file where required ? I have zf2 Zend_db module download with phyrus and installed at the location vendor/zf2/php . I tried adding the module to the include path with the following command: set_include_path("../vendor/zf2/php".PATH_SEPARATOR.get_include_path()); I created Model class files relevant to each table (using zend-db-model-generator) inside directory Model/ . my main app contains the following: use

doctrine 2 oracle datetime column showing “not a valid month” on insert entity

老子叫甜甜 提交于 2019-12-05 21:57:33
I am working on a project where we are using Zend 2 and doctrine 2 with oracle database. my entity has a field create_date with datetime type. my entity are below class Personnel { /** * @ORM\Column(type="string",unique=true, nullable=false) */ protected $login_name; /** * @ORM\Column(type="datetime") */ protected $create_date; public function __construct() { $this->create_date = new \DateTime("now"); } public function get_login_name() { return $this->login_name; } public function set_login_name($login_name) { $this->login_name = $login_name; } } and im saving this entity with $user = new

Zf2 - How to set cookie

*爱你&永不变心* 提交于 2019-12-05 21:24:09
问题 I found this topic Zend Framework 2 - Cookie Concept while I was searching for info about setting cookie in ZF2, but seems like information included in that topic are out of date. I have tried following code: public function indexAction() { $request = $this->getRequest()->getHeaders()->get('Set-Cookie')->foo = 'bar; $response = $this->getResponse()->getCookie()->baz = 'test'; var_dump($_COOKIE); ... return new ViewModel(); } Both lines output warning: Warning: Creating default object from

Gearman, ZF2, Doctrine2, MySQL, SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

杀马特。学长 韩版系。学妹 提交于 2019-12-05 20:55:38
I use ZF2, Doctrine2, MySQL, Gearman. When working Gearman periodically has an error: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away. I tried these steps to fix the problem: 1) I investigated MySQL queries. Queries haven't any problem. It's simple (without subqueries) and fast. For example, this is EXPLAIN of one of queries when MySQL server has gone away. +-------------+-------+-------+-----------------------+-----------------------+---------+-------+------+ | select_type | table | type | possible_keys | key | key_len | ref | rows | +-------------+-------+-------+------------

validating date in zendframework2

时光怂恿深爱的人放手 提交于 2019-12-05 19:48:12
Hiho, I would like to validate a date field from an zf2 form. I set the 'format' option to get the format I need. But at every time I validate it i get an error. The validator looks like this: $inputFilter->add($factory->createInput(array( 'name' => 'user_data_birth', 'required' => false, 'validators' => array( array( 'name' => 'Date', 'options' => array( 'format' => 'd.m.Y', 'locale' => 'de', 'messages' => array( \Zend\Validator\Date::INVALID => 'Das scheint kein gültiges Datum zu sein.', \Zend\Validator\Date::INVALID_DATE => 'Das scheint kein gültiges Datum zu sein. (Invalid Date)', \Zend

How do I turn on the PHP error reporting in Zend Framework 2?

夙愿已清 提交于 2019-12-05 19:38:57
问题 Everytime I receive an error in Zend Framework 2, I get just 500 Internal Server Error displayed and have to search through the Zend Server error log. I've tried putting this to my config/autoload/local.php file but it doesn't work: return array( 'phpSettings' => array( 'display_startup_errors' => true, 'display_errors' => true, ), ); 回答1: There is no native support for that in zf2 (afaik). You'd either have to set them in php.ini itself, or set them in index.php <?php error_reporting(E_ALL);

Doctrine - How to extract results and their relationships as array

回眸只為那壹抹淺笑 提交于 2019-12-05 18:45:23
I have an entity, call it Stones and Stones has a ManyToMany relationship with Attributes. So I query the entity to get the Stones and then I hydrate this to convert it into an array. $result = $this->stoneRepository->find($stone_id); if ( ! $result ) { return false; } $resultArray = $this->doctrineHydrator->extract($result); This works fine for the Stone entity however I noticed that the join (Attributes) remain as objects. array (size=12) 'id' => int 1 'name' => string 'Agate' (length=5) 'title' => string 'Title' (length=5) 'attribute' => array (size=5) 0 => object(Stone\Entity\StAttribute)