zend-framework

How to use union in zend db

心已入冬 提交于 2019-12-19 07:39:13
问题 In sql i am using union i don't know how to write it in zend db. select m.*, 0 as is_shared from test m where user_id = $userId union select m.*,1 as is_shared from test m join test_shares ms where m.test_id = ms.test_id and ms.email_address = $email and m.url is not null; Please help me out.... I tried like this but no use $cols1 = array('test.*,0 as is_shared'); $select1 = $db->select () ->from ( 'test', $cols1 ) ->where ( 'user_id = ?', $userId); $cols2 = array('test_shares.*', '1 as is

How to Set a Value to NULL when using Zend_Db

回眸只為那壹抹淺笑 提交于 2019-12-19 07:19:42
问题 When performing UPDATE and INSERT queries using Zend_Db, I frequently need to set values equal to NULL (not ''). However, the default behavior of Zend_Db::insert() and Zend_Db::update() seems to be that values that are empty are translated into empty strings ('') and put into the database as such. Does anyone know of way to actually force a NULL value to go into fields if the value is empty in php? 回答1: Try setting the affected fields to: new Zend_Db_Expr('NULL') 回答2: I've always just been

Use Zend Framework components without the actual framework?

五迷三道 提交于 2019-12-19 07:06:07
问题 I was wondering if anyone knew how to use some components of the Zend Framework without having to actually use the framework. For example, I would like to use their Zend_Validate components, but don't want the overhead of the framework as it's a small one-page script. Can this be easily done, and if so, are there guides/tutorials on how to accomplish it? 回答1: Zend framework components are intentionally designed to be loosely couple from the framework itself. The component structure of Zend

Control access to files available for download

亡梦爱人 提交于 2019-12-19 04:55:16
问题 I have a folder that contains uploaded documents that my ZF application can spit out to logged in users. I want them to be able to use a link like http://server/documents/filename.pdf and download the file, but I want to have a controller DocumentsController that enables the existing user cookies to verify that they are logged in and have permission to download the file. I don't want to have to use URLs like http://server/documents/index/id/1 if I don't have to, though its not a terrible

Add a regex validator to a form element in the Zend Framework

白昼怎懂夜的黑 提交于 2019-12-19 04:42:34
问题 I created a Form class in zend Framework. class Application_Form_UserSignup extends Zend_Form { public function init() { // Set the method for the display form to POST $this->setMethod('post'); // Add an Firstname element $this->addElement('text', 'firstname', array( 'label' => 'Your first name:', 'required' => true, 'validators' => array('regex', false, array( 'pattern' => '/[^<>]/i', 'messages' => 'Your first name cannot contain those characters : < >')) )); } } I would like to validate it

error in zend session database for php7

我与影子孤独终老i 提交于 2019-12-19 04:14:34
问题 My application need to use database instead of file for the session management . My Application is based on Zend Framework 1.12.17, php 5.6.25 and actualy on wampserver That is my config.ini resources.session.use_only_cookies = true resources.session.gc_maxlifetime = 864000 resources.session.remember_me_seconds = 864000 resources.session.gc_probability = 1 resources.session.gc_divisor = 100 resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable" resources.session.saveHandler

How to set charset to UTF-8 in a Zend application?

前提是你 提交于 2019-12-19 03:08:33
问题 I am developping a Zend application. The data in my database is encoded in "utf8_unicode_ci". I declared in my application.ini : resources.view.encoding = "UTF-8" but whenever I try to retrieve a String containing special characters like {'é', 'à', 'è',...} in the db, the string doesn't display unless I use the function : utf8_decode() So I tried to set the charset to UTF-8 in : Bootstrap : protected function _initDoctype() { $this->bootstrap('view'); $view = $this->getResource('view'); $view

Magento : How to check if admin is logged in within a module controller?

南楼画角 提交于 2019-12-18 19:27:08
问题 I'm creating a Magento Module. Within the controller, I want to check if an admin is logged in or not. So the controller only will be accessible if there is a logged in admin. I'm trying to use this code on my controller. Mage::getSingleton('core/session', array('name' => 'adminhtml')); $session = Mage::getSingleton('admin/session'); // Use the 'admin/session' object to check loggedIn status if ( $session->isLoggedIn() ) { echo "logged in"; } else { echo "not logged in"; } but I always get

Formatting the results of a MySQL query as if it were run from the console

走远了吗. 提交于 2019-12-18 19:09:32
问题 I'm writing a quick and dirty reporting script that queries a report and emails the results. When using the MySQL console the results are in a nicely formatted table: mysql> select * from users; +-----------+------------+-------+ | firstname | city | zip | +-----------+------------+-------+ | Maria | Holland | 12345 | | Rene | Doylestown | 65432 | | Helen | Conway | 98745 | +-----------+------------+-------+ 3 rows in set (0.01 sec) Is there an easy way to replicate this formatting when

Zend Framework 2 and Doctrine 2 - Configuration for multiple databases

牧云@^-^@ 提交于 2019-12-18 17:54:09
问题 I pasted the code from the configuration.md file to module.config.php 'doctrine' => array( 'connection' => array( 'orm_crawler' => array( 'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver', 'params' => array( 'host' => 'localhost', 'port' => '3306', 'user' => 'root', 'password' => 'root', 'dbname' => 'crawler', 'driverOptions' => array( 1002 => 'SET NAMES utf8' ), ) ) ), 'configuration' => array( 'orm_crawler' => array( 'metadata_cache' => 'array', 'query_cache' => 'array', 'result_cache