2

I know that this statement updates the record in the zend framework. But I want to understand the complete flow of this statement. Statement is

$request->update($data,$request->getAdapter()->quoteInto('id = ?',$this->getRequest()->getParam('selected_id'))) )
$data is the array of records that is passed to it and $request is the object of model. I want to know whole meaning of this statement
hakre
  • 193,403
  • 52
  • 435
  • 836
Awais Qarni
  • 17,492
  • 24
  • 75
  • 137
  • naming DbModel variable $request is really bad practice :) – Tomáš Fejfar Apr 13 '11 at 10:09
  • @Tomas Fejfar Thanks dude for your suggestion but what is good practice? – Awais Qarni Apr 13 '11 at 12:46
  • 1
    it was kind of a joke (insider joke to be precise) :) $request and $response are usually Request and Response object (meaning HTTP request and response). You should name it so, that it resembles the contents and not colide with common objects (db, registry, request, ...). – Tomáš Fejfar Apr 13 '11 at 15:00
  • 1
    Everyone usually thinks, that if a variable is called $request, it holds Zend_Http_Request... ;) – Tomáš Fejfar Apr 13 '11 at 15:00
  • @Tomas Fejfar... Nice point, I'll take care of it.. Actually I am having a Request Management Module within a system, that's why I named it so... But good point raised by you.. Thanks – Awais Qarni Apr 14 '11 at 05:18

1 Answers1

2

As you know update statement uses $table->update($data, $where);

$request is db table model. ->getAdapter gets the adapter.

Also quoteInto() is best defined as by documentation

The most typical usage of quoting is to interpolate a PHP variable into a SQL expression or statement. You can use the quoteInto() method to do this in one step. This method takes two arguments: the first argument is a string containing a placeholder symbol (?), and the second argument is a value or PHP variable that should be substituted for that placeholder.

And the last expression $this->getRequest()->getParam('selected_id').

$this->getRequest() gets the request $_GET type

And getParam('selected_id')) fetches selected_id of GET object.

S L
  • 14,262
  • 17
  • 77
  • 116