zend-framework

What are differences between XMLHttpRequest and HttpRequest

久未见 提交于 2019-12-13 00:12:13
问题 In Zend Framework and other framework such as Symfony, there is a method named isXMLHttpRequest() to determine this is XMLHttpRequest or not. I wonder that how can framework or PHP distinguish between XmlHttpRequest and HttpRequest? if($this->_request->isXmlHttpRequest()) { //code here } 回答1: From the documentation: Zend_Controller_Request_Http has a rudimentary method for detecting AJAX requests: isXmlHttpRequest(). This method looks for an HTTP request header X-Requested-With with the value

Increment a column in MySQL

爱⌒轻易说出口 提交于 2019-12-12 23:31:53
问题 Is there a way in Zend to increment an integer, held in a MySQL column, by 1? Thanks edit: My current code is like: $row = $this->find($imageId)->current(); $row->votes = // THIS IS WHERE I WANT TO SAY INCREMENT $row->save(); 回答1: Might I offer the following suggestion $row->votes++; 回答2: Yes there is. Here's an example using products and incrementing a quantity field: $table = 'products'; $data = array('prd_qnty' => new Zend_Db_Expr('prd_qnty + 1')); $where[] = $db->quoteInto('pr_id = ?',

Possible to download a file through the Zend HTTP Client?

三世轮回 提交于 2019-12-12 23:04:08
问题 I am trying to build a script where it downloads a file using the Zend http client: http://framework.zend.com/manual/en/zend.http.html but I can't find anywhere where it says how to do this so I'm wondering if its possible... The file is dependent on being logged in so I need to have it done through the zend http client so it can make use of the cookies that are created when the script logs in.. any advice is greatly appreciated 回答1: Complete the request for the file just like you would a

How to properly Autoload Doctrine ODM annotations?

假如想象 提交于 2019-12-12 21:09:09
问题 Trying to run the command line tool w/ odm:schema:create and I'm getting errors like: "[Semantical Error] The annotation "@Document" in class Company_Model_Auth was never imported. Did you maybe forget to add a "use" statement for this annotation?" and "[Semantical Error] The annotation "@EmbeddedDocument" in class Company_Model_Auth was never imported. Did you maybe forget to add a "use" statement for this annotation?" as well as others, basically for every annotation. When I add "use

How does one convert complex SQL queries into Zend_Db_Select statements?

半世苍凉 提交于 2019-12-12 20:05:35
问题 The MySQL website has an excellent tutorial on storing hierarchal data in a database. I'm trying to write the query that returns a node's immediate children. I don't want to just copy/paste the query from the MySQL website, because I'm trying to work on this in a database agnostic manner. This is the query I'm trying to Zend_Db_Select-ify SELECT node.name, (COUNT(parent.name) - (sub_tree.depth + 1)) AS depth FROM nested_category AS node, nested_category AS parent, nested_category AS sub

How to set the content type with Zend_Http_Client on PUT?

冷暖自知 提交于 2019-12-12 19:58:59
问题 Hi I'm refactoring following curl call to a Zend_Http_Client call. This will send a PUT request to a CouchDB database with the given file and set the correct Content-Type for the _attachement. exec( 'curl -s -X PUT ' . $url ' . '--data-binary @\'' . $filePath . '\' -H "Content-Type: ' . $mimeType . '"', $resultJson, $returnCode ); Refactored to Zend_Http_Client I've got the following: $adapter = new Zend_Http_Client_Adapter_Curl(); $client = new Zend_Http_Client(); $client->setAdapter(

php HTTP tunnel to IMAP/POP3 using SSL

青春壹個敷衍的年華 提交于 2019-12-12 19:48:19
问题 My code should check email boxes via proxy with PHP using SSL. Zend\Mail package provides implementation of both protocols without php extention and fits fine. I partially override connect() method by code: $this->socket = fsockopen($proxy, $proxy_port, $errno, $errstr, self::TIMEOUT_CONNECTION); $this->sendRequest("CONNECT {$host}:{$port} HTTP/1.1"); $this->sendRequest("Host: {$host}:{$port}"); $this->sendRequest($userAgent); $this->sendRequest("Proxy-Authorization: basic " . base64_encode("

How capture the default.phtml in a variable inside a controller

走远了吗. 提交于 2019-12-12 18:52:05
问题 I have a simple question... How could I render the contents of the default.phtml which is in Project/application/layouts/scripts/default.phtml to a variable, so I can have its html. In the index controller, with an action and a phtml file named test, this would work: $html = $this->view->render('index/test.phtml'); But, of course, this does not: $htmlDefaultLayout = $this->view->render('default.phtml'); Since default.phtml is not inside any controller, I guess. Is there a good way to do that?

Zend Framework: Zend_translate and routing related issue

亡梦爱人 提交于 2019-12-12 18:40:49
问题 I have implemented Zend_Navigation, Zend_Translate in my application. The routing is setup in Bootstrap.php like below. $fc = Zend_Controller_Front::getInstance(); $zl=new Zend_Locale(); Zend_Registry::set('Zend_Locale',$zl); $lang=$zl->getLanguage().'_'.$zl->getRegion(); $router = $fc->getRouter(); $route = new Zend_Controller_Router_Route(':lang/:module/:controller/:action/*', array( 'lang'=>$lang, 'module'=>'default', 'controller'=>'index', 'action'=>'index' )); $router->addRoute('default'

FirePHP doesn't always write log messages

纵然是瞬间 提交于 2019-12-12 18:39:28
问题 I set my loggers up in my Bootstrap.php like so: $logger = new Zend_Log(); if($environment->debug == '1') { $stream = @fopen('/var/www/html/rta/rta.log','a',false); if(!$stream){ throw new Exception('Failed to open log stream'); } $writer = new Zend_Log_Writer_Stream($stream); $logger->addWriter($writer); $logger->addWriter(new Zend_Log_Writer_Firebug()); } else { // Do something else } Zend_Registry::set('logger',$logger); I have the following code that I set up to fail: $data = array(