zend-framework2

How to use Facebook PHP SDK with Zend Framework 2

自闭症网瘾萝莉.ら 提交于 2019-12-10 11:36:24
问题 I want to be able to use the Facebook PHP SDK with the new ZEND Framework 2 platform. How to do it? Zend Framework 2 is quite different as previous version ZF1. When I try the standard PHP in the main application controller IndexController': require_once("facebook.php"); class IndexController extends AbstractActionController { public $facebook; public function __construct() { $this->facebook = new Facebook(array( 'appId' => 'appId', 'secret' => 'secret_key' )); } /* ... */ } I get following

Issue in Create new Controller in Zend Framework 2 (ZF2)

穿精又带淫゛_ 提交于 2019-12-10 11:32:44
问题 I am using ZF2 Skeleton app. To create a new controller in a existing Module, I modified the module.config.php file like this: <?php return array( 'controllers' => array( 'invokables' => array( 'Album\Controller\Album' => 'Album\Controller\AlbumController', // WORKING FINE 'Album\Controller\Photo' => 'Album\Controller\PhotoController', // I ADDED THIS ), ), // The following section Was PREVIOUSLY THERE 'router' => array( 'routes' => array( 'album' => array( 'type' => 'segment', 'options' =>

ZF2 fileprg with files in collection

流过昼夜 提交于 2019-12-10 11:27:31
问题 I can't get fileprg plugin to work with the files in a collection. I am trying to upload multiple files using FormCollections , but in $form->getData() there is no key related to my collection or the files . I tested the form and fileprg with simple file input (in the same form) and it worked uploaded/renamed and it was in the $form->getData() . what am i missing ? is there anything special to be done with the collections to get it to work ? 回答1: In the file \Zend\Mvc\Controller\Plugin

multidimensional array session container in zend framework 2

杀马特。学长 韩版系。学妹 提交于 2019-12-10 11:19:01
问题 I am working on an application using zend framework 2 session array containers. I can create the session using array containers as mentioned in zend 2 document, but i am getting the problem while creating the session with multidimensional arrays. I want to update the session everytime since i am updating the values for shopping cart. I am trying with the below code, its not updated rather the session values are getting changed. $container = new Container('test'); $values = array(); $values[

ZF2 Re-starting service manager key

你离开我真会死。 提交于 2019-12-10 11:14:49
问题 I have a database adapter stored in my service manager called "dbAdapter". I am looking for a way to disconnect and then re-connect to this adapter using a slightly different configuration, possibly several times. The reason is that I have many customers who's database structure is 100% is the same. I am writing a cron job that will do maintance on each database but it has to connect to the first one, do its thing, drop the connection and connect to the next one...until it is out of databases

How to count number of rows within Zend Framework 2

送分小仙女□ 提交于 2019-12-10 10:46:56
问题 I need to count result rows of MySql query. here I extended TableGateway class to my class this is my code. public function get_num_of_rows(){ $sql = 'SELECT count(q_no) FROM questions'; //code ???????????????? $result = $this->select(); return $result; } So how I execute SELECT count(q_no) FROM questions ? 回答1: There is no need to write own sql query. When you do $this->select(), you get an instance of Zend\Db\ResultSet\ResultSet. ResultSet has method count. $result = $this->select(); return

injecting ServiceLocator via ServiceLocatorAwareInterface doesnt work

不问归期 提交于 2019-12-10 10:25:05
问题 i read that implementing: ServiceLocatorAwareInterface will inject the serviceLocator to the same class. So I got this: Class MyModel implements ServiceLocatorAwareInterface { protected $serviceLocator; public function setServiceLocator(ServiceLocatorInterface $serviceLocator) { $this->serviceLocator = $serviceLocator; } public function getServiceLocator() { return $this->serviceLocator; } } But $this->serviceLocator is always NULL Do i have to do more than that? 回答1: You have to register

Translation of database with poedit and zend translate

独自空忆成欢 提交于 2019-12-10 10:08:56
问题 Poedit does not automatically recognise the content of a table in a database. What is the best way to get the content of a table recognized by poedit for its translation in zend. I would like it to be done automatically....do I have to create an xml file from the database ? 回答1: You should not translate database contents with poedit. You would do that inside the database. The short answer: what you want cannot be achieved, unfortunately. You can translate "fixed" strings and if you want to

Doctrine2: [Semantical Error] Cannot select entity through identification variables without choosing at least one root entity alias

一曲冷凌霜 提交于 2019-12-10 10:08:39
问题 This is my query with query builder, and it works perfectly, bringing all the results of user table and the modules table, which has a many to many association: public function getUser($id){ $qb = $this->getEm()->createQueryBuilder() ->select('u', 'm') ->from('Adm\Entity\User', 'u') ->join('u.modules', 'm') ->where('u.id = ?1') ->setParameters(array(1 => $id)); $result = $qb->getQuery()->getResult(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY); return $result; } But when i try to select specific

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

独自空忆成欢 提交于 2019-12-10 10:04:57
问题 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