zend-framework

Zend Framework: How to find a table row by the value of a specified column?

此生再无相见时 提交于 2020-01-13 11:59:10
问题 I am implementing my model exactly like the quickstart guide. In my model I am trying to implement a findByToken() method. The current find() method accepts an $id parameter, but I want to find by the value of a different column. //excerpt from the quickstart guide public function find($id, Default_Model_Guestbook $guestbook) { $result = $this->getDbTable()->find($id); if (0 == count($result)) { return; } $row = $result->current(); $guestbook->setId($row->id) ->setEmail($row->email) -

MySQL remove space before order by clause

a 夏天 提交于 2020-01-13 11:28:10
问题 I have a table full of "title" that I want to order by title. Problem is a lot of them have a empty space before the title. I am thinking of writting a php script to fix it all (super easy) but I was curious how could I do: SELECT * FROM products ORDER BY title But at the same time trimming the title so it doesnt order on the empty space. All in the same query without changing the data. God I hope I make sense. So I am really looking for a mysql solution to this. For what its worth I use Zend

how to include file in zend framework controller?

血红的双手。 提交于 2020-01-13 11:06:08
问题 hello I am newbie in zend framework .. I want to know how to includes files in zend framework Controller I am using action in zend framework controller like that public function anyAction() { require("../mailchimp/anyfile.php"); } what I can do to include this files, means where is the right place to kept all this files 回答1: This is what the library directory is typically used for. You can put your own functions in there as well as any 3rd party code. Some even put the ZF library in there,

[zend][db] fetchAll with multiple variables

岁酱吖の 提交于 2020-01-13 10:04:49
问题 I'm trying to use fetchAll on a query that has 2 variables. I can't figure out the syntax. I can manage with only 1 variable: $sql = "SELECT * FROM mytable WHERE field1 = ?"; $this->_db->fetchAll($sql,$value1); # that works However I'm having some issues when query has multiple variables $sql = "SELECT * FROM mytable WHERE field1 = ? AND field2 = ?"; $this->_db->fetchAll($sql,$value1,$value2); # doesn't work $this->_db->fetchAll($sql,array("field1"=>$value1,"field2"=>$value2)); # doesn't work

Attachment name and file extension not working in email *.eml

荒凉一梦 提交于 2020-01-13 09:55:34
问题 I want to create email files in .eml format with multiple attachments in. The attachments are generated and the content of the attachments are correct. But the attachments always come in .dat format and the file names go as "ATT00001", "ATT0002".. etc Currently I am following the solution given in this stackoverflow question and my code is as follows PHP foreach($reports as $pdf){ $attachment = file_get_contents("auto_report_attachments\\Template_Attachment.eml"); $attachment = str_replace(

Passing values to the Layout in Zend Framework…?

我是研究僧i 提交于 2020-01-13 08:51:15
问题 I am facing a problem in zend-framework related to layout . Here I have to pass some values to the layout that will be used to display the top-ranking users of the site. Since I am new to zend-framework, I'm not able to find any way to do so. If you have any code, idea or link, please provide me..... Thanks in advance........... 回答1: Create a Controller Plugin that fetches this data anytime before the layout is rendered and pass the data to to the view. Then render that data on your layout

Zend form setRequired(true) or addValidator(NotEmpty)

£可爱£侵袭症+ 提交于 2020-01-13 08:01:07
问题 Is there any real difference between the behavior or output of these 2. They look to me like they do the same thing. ->addValidator('NotEmpty') ->setRequired(true) 回答1: Yes, there's a difference. If an element is not required, it'll validate even if the whole value is missing from the data you validate against. The value is only validated against registered validators after it's been determined that it exists. NotEmpty validator will only fail if the field is present, but is empty. Also, it's

Zend framework SQL select query construction (WHERE CLAUSE)

时光总嘲笑我的痴心妄想 提交于 2020-01-13 07:14:30
问题 I am trying to generate a query that selects all from a user table where any combination of the last name of first name matches a particular search term $select = $select->where('last_name LIKE ?', '%'.$term.'%')->orWhere('first_name LIKE ?', '%'.$term.'%') ->orWhere("CONCAT(first_name,' ', last_name) LIKE ?", '%'.$term.'%') ->orWhere("CONCAT(last_name,' ', first_name) LIKE ?", '%'.$term.'%'); There is another condition that has to also has to be met which is specified in another where clause

how we could create translate validate error messages on zend framework?

南笙酒味 提交于 2020-01-13 06:07:49
问题 how we could create translate validate error messages on zend framework? someone could give a example ? thanks 回答1: From the ZF Manual on Zend_Validate Validation Messages $validator = new Zend_Validate_GreaterThan(); $validator->setMessage('Please enter a lower value', Zend_Validate_GreaterThan::NOT_GREATER); And also: Zend Framework is shipped with more than 45 different validators with more than 200 failure messages. It can be a tendious task to translate all of these messages. But for

Expire the Zend session if the user remains idle for 10 minutes

江枫思渺然 提交于 2020-01-13 06:02:28
问题 I am new to zend and I want to ask how can I expire a user's session namespace's particular key if a user remains idle for 10 minutes. I have a namespace defined in zend session as $session = new Zend_Session_Namespace('loginNamespace'); now when the user logs in I set the key loggedIn = 1 in session namespace. Now I want to expire not the whole session if the user remains idle but only that key. how can I do that? 回答1: From the documentation, you can expire a key using: $session-