zend-framework

How to connect to DB, when running via command line

点点圈 提交于 2019-12-09 14:54:43
问题 When I run zend framework project from browser, everything is OK, it connects to DB. When I run project from command line it can't connect to DB and it throws an error: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in /usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Abstract.php:129 I have used Running a Zend Framework action from command line 's answers ( https://stackoverflow.com/a/4706966/457033 ) It's my

Zend_Test - Setting redirect in Controller Plugin for PHPUnit

◇◆丶佛笑我妖孽 提交于 2019-12-09 13:42:06
问题 I have been trying to use PHPUnit to test an application. I have it all working, but cannot test redirects. My redirects are occurring inside an Acl Controller Plugin, not inside an Action in a Controller. I have changed them to use the suggested format of $r = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $r->gotoSimple("index", "index", "default"); But this fails in the tests, the response body is empty and I get errors like Zend_Dom_Exception: Cannot query; no

Execute code after HTTP request is complete in PHP?

泄露秘密 提交于 2019-12-09 13:26:52
问题 PHP provides a mechanism to register a shutdown function: register_shutdown_function('shutdown_func'); The problem is that in the recent versions of PHP, this function is still executed DURING the request. I have a platform (in Zend Framework if that matters) where any piece of code throughout the request can register an entry to be logged into the database. Rather than have tons of individual insert statements throughout the request, slowing the page down, I queue them up to be insert at the

Whats the way to use Zend_Acl in View to show/hide parts of view

拜拜、爱过 提交于 2019-12-09 13:09:30
问题 I am wondering whats the way to use Zend_Acl to show/hide parts of view? I am thinking I will Create a Controller Plugin that passes the logged in user + acl to view $this->view->loggedInUser = Zend_Auth::getIdentity(); $this->view->acl = Zend_Registry::get('acl'); Then in view scripts do something like $this->acl->isAllowed($this->view->loggedInUser, 'resource', 'privilege'); Or is there a better way? Or should I use a View Helper? That returns a boolean whether the logged in user is allowed

Zend Framework: Using Dashes in Controller Names/URLs

与世无争的帅哥 提交于 2019-12-09 13:05:09
问题 I have a URL I would like to look something like http://server/my/action-name Obviously, I can't have a - in the ControllerName function and an underscore doesn't work. Is this even possible? 回答1: By default http://server/my/action-name will map to MyController::actionNameAction() but you can also setup arbitrary routes with the Standard Router. 回答2: use camel casing. It works for actions: function actionNameAction() 来源: https://stackoverflow.com/questions/3426036/zend-framework-using-dashes

Making your PHP website into SAML Identity Provider

£可爱£侵袭症+ 提交于 2019-12-09 11:17:16
问题 Story is that I need to make my website act as Identity Provider (read: IDP). Website itself is on Zend platform. Idea is making a IDP controller by which Service Providers (read: SP) contacts IDP. As it must be part of the website, I would need to include some extension, which could be easily used for responding SAML requests from SP. I have found list of PHP extensions from: https://wiki.surfnetlabs.nl/display/OSP/RFC+-+OpenSAMLphp,+a+new+PHP+library+for+SAML+2.0+support All of these

How to get Column Name With Zend DB

好久不见. 提交于 2019-12-09 09:01:56
问题 How to get Column Name With Zend DB 回答1: This is the correct answer, the older answers are wrong or outdated: $cols = $table->info(Zend_Db_Table_Abstract::COLS); 回答2: $metadata = $db->describeTable($tableName); $columnNames = array_keys($metadata); http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.list-describe 回答3: Previous answer applies only to version < 2. For current version of ZF (2.2) use: $table = new Zend\Db\TableGateway\TableGateway('table', $Dbadapter, new Zend\Db

Why does Magento use 2 cookies per session?

。_饼干妹妹 提交于 2019-12-09 08:47:57
问题 For data security and privacy reasons I want to know why Magento uses two cookies for one frontend session. All I know is that one of them is being set in Mage_Core_Model_Cookie::set(..) and the other one in Zend_Session::expireSessionCookie() , but still I can't seem to figure out what they are used for. I just can't think of any reason why one would need a second cookie for the same domain. 回答1: I'm going to call this one vestigial code. Varien relies heavily on the Zend Framework as the

How to use bind variables with Zend_Db_Table->update() in the where clause

牧云@^-^@ 提交于 2019-12-09 07:55:27
问题 If I want to use the Zend_Db_Table->update() method to update my table with data, I cannot find anyway to use bind variables in the "where" clause. The method signature is: int update($data, array|string $where) Usually you will call the method like this: $table = new Bugs(); $data = array( 'updated_on' => '2007-03-23', 'bug_status' => 'FIXED' ); $where = $table->getAdapter()->quoteInto('bug_id = ?', 1234); $table->update($data, $where); quoteInto is just going to escape the variable, not

Why is this code to center text on a PDF using the PHP Zend_Pdf Library not working?

 ̄綄美尐妖づ 提交于 2019-12-09 06:14:20
问题 I'm attempting to dynamically create PDF documents on the server and send them to the client using the Zend_Pdf library. All text on the PDF needs to be center aligned to the page, which will be letter-sized, landscape. Using functions that I have found multiple times on various sites, I'm having a problem - the center justification is off. All text is appearing way too far to the left. Here is my code: <? require('Zend/Pdf.php'); $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT