::execute() must be compatible with that of sfComponent::execute()

This is since 1.1 or greater version of symfony:

class testAction extends sfAction{
public function execute() {

}

}

The above code will work fine for symfony 1.0, but for the versions above it; it won’t work.

Below given is the change you need to implement to make it work

class testAction extends sfAction{
public function execute($request) {

}

}

symfony cheat sheet

Hi people, below given is the list of attached symfony cheatsheets. Help yourself with this

sfviewsecondpartrefcard

sfviewfirstpartrefcard

sfservervalidationrefcard

sform_enus

sfmodelsecondpartrefcard

sfmodelcriteriacriterionrsrefcard_enus

lime-cheat

cheatsymfonyjshelper_enus

cheatsymfony004forms

Secure SSL(https) Redirect Filter for Symfony

please follow the steps given below to put up specific page to https or secure url:

1) First add the following settings to your app.yml file:

all:
  ssl:
    insecure_host:    www.avidindiainc.com/blog
    secure_host:      www.avidindiainc.com    
    secure_actions:
      - { module: shop, action: register }
      - { module: shop, action: checkout }
      - { module: register, action: updateCardDetails }

2) Next we add our filter code to lib/sslFilter.class.php (apps/[application name]/lib):

/**
 * Filter for redirecting to SSL for the pages that need it
 *
 * @author Sachin Makwana <sachin@avidindiainc.com>
 * @version 2
 */
class sslFilter extends sfFilter
{
  /**
   * Execute filter
   *
   * @param FilterChain $filterChain The symfony filter chain
   */
  public function execute ($filterChain)
  {
    // Only execute this filter once
    if ($this->isFirstCall() && SF_ENVIRONMENT != 'dev') {
      // Array of modules/actions that require move to SSL
      $ssl_actions = sfConfig::get('app_ssl_secure_actions');

      if (empty($_SERVER['HTTPS']) && count($_POST) < 1) {

        // We're not using SSL and not POSTing data - check if we should be using SSL
        foreach ($ssl_actions as $action) {
          if ($this->getContext()->getModuleName() == $action['module'] && $this->getContext()->getActionName() == $action['action']) {
            $new_url = sprintf('https://%s%s', sfConfig::get('app_ssl_secure_host'), $_SERVER['REQUEST_URI']);
            header('Location: ' . $new_url);
            exit;
          }
        }

        // Using secure host when not required - not good
        if ($_SERVER['HTTP_HOST'] == sfConfig::get('app_ssl_secure_host')) {
          $new_url = sprintf('http://%s%s', sfConfig::get('app_ssl_insecure_host'), $_SERVER['REQUEST_URI']);
          header('Location: ' . $new_url);
          exit;
        }
      } elseif (!empty($_SERVER['HTTPS']) && count($_POST) < 1) {

        // We're using SSL and not posting data
        $dont_redirect = false;
        foreach ($ssl_actions as $action) {
          if ($this->getContext()->getModuleName() == $action['module'] && $this->getContext()->getActionName() == $action['action']) {
            $dont_redirect = true;
          }
        }
        if ($dont_redirect == false) {
          // Redirect
          $new_url = sprintf('http://%s%s', sfConfig::get('app_ssl_insecure_host'), $_SERVER['REQUEST_URI']);
          header('Location: ' . $new_url);
          exit;
        }
      }
    }
    // Next filter
    $filterChain->execute();
  }
}

3) Finally, enable your sslFilter in the application’s config/filters.yml configuration file:

sslFilter:
  class:  sslFilter

update query in symfony

$con = Propel::getConnection();

// select from…

$c1 = new Criteria();

$c1->add(FacilitiesBookingsPeer::FAB_ID, $fabId);

 

// update set

$c2 = new Criteria();

$c2->add(FacilitiesBookingsPeer::FAB_SLOTS, $newSlot);

BasePeer::doUpdate($c1, $c2, $con);

 

here in the code given above $c1 stands for “where” criteria of query

while $c2 stands for the fields to be updated. also you can add other fields to be updated if you want.

the last line of the code block “BasePeer::doUpdate($c1, $c2, $con);” remains as it is.  while the others are according to your table in action. here we have “FacilitiesBookingsPeer::FAB_SLOTS ”  FacilitiesBookingsPeer is table and  FAB_SLOTS is the field name to be updated

observe field in symfony

While using observe_field , pls take a note that never use ‘with’ => “‘regCode=’ + $(‘region’).value” instead of that  use :’with’ => “‘regCode=’+value” as the former method is incompatible with lower versions of firefox

echo(observe_field(‘region’, array(‘update’ => ‘updateCountry’, ‘url’ => ‘default/updateCountry?className=DrpDwnBox194FL’,’script’=>true, ‘with’ => “‘regCode=’ + $(‘region’).value”, ‘loading’  => “Element.show(‘loadingId’);Element.hide(‘updateCountry’)”, ‘complete’ => “Element.hide(‘loadingId’);Element.show(‘updateCountry’)”)));

——————
echo(observe_field(‘region’, array(‘update’ => ‘updateCountry’, ‘url’ => ‘default/updateCountry?className=DrpDwnBox194FL’,’script’=>true, ‘with’ => “‘regCode=’+value”, ‘loading’  => “Element.show(‘loadingId’);Element.hide(‘updateCountry’)”, ‘complete’ => “Element.hide(‘loadingId’);Element.show(‘updateCountry’)”)));

writing a custom query in symfony

//it is javascrit file need to include at run time in ajax
$this->response = $this->getResponse();
$this->response->addJavascript(‘/sf/prototype/js/prototype’);
$this->response->addJavascript(‘/sf/prototype/js/effects’);
$this->response->addJavascript(‘/sf/prototype/js/controls’);
//end  javascript of file need to include at run time in ajax

$selSearch = $this->getRequestParameter(‘selSearch’);
$txtSearch = $this->getRequestParameter(‘txtSearch’);
$extrVar =’&mainpg=1′;
if($selSearch) $extrVar .=’&selSearch=’.$selSearch;
if($txtSearch) $extrVar .=’&txtSearch=’.$txtSearch;

$userId = $this->getUser()->getAttribute(‘userId’);
$this->currentUserId = $userId;

$objUser = UserPeer::retrieveByPK($userId);
$countryCode = $objUser->getUsrCountry();

//$endodedURL = $this->getRequestParameter(‘endodedURL’);

//$this->endodedURL = $endodedURL;

//here replacing the following special character – , _ , + , * , / , #
$txtSearchwithSpace = preg_replace(“[%]”,’\%’,addslashes(preg_replace(“@[-_+*/#]@”,” “,$txtSearch)));
$txtSearchwithoutSpace = preg_replace(“[%]”,’\%’,addslashes(preg_replace(“@[-_+*/#]@”,””,$txtSearch)));
$txtSearch = addslashes($txtSearch);
$txtSearch = preg_replace(“[%]”,’\%’,preg_replace(“[_]”,’\_’,$txtSearch));

$objQtzReagent = new qtzReagent();

$sqlQuery = “”;
$sqlQuery = “SELECT SQL_CALC_FOUND_ROWS “.ReagentsPeer::REA_NAME.” AS rea_name_old, “.ReagentsPeer::REA_VENDORID.” AS rea_vendorid, “.ReagentsPeer::REA_CATALOGUEID.” AS rea_catalogueid, “.ReagentsPeer::REA_CATALOGUEID.” AS rea_catalogueid_R, IF( “.ReagentsPeer::REA_USRID.” = ‘”.$this->currentUserId.”‘,’yes’,’no’) AS reagent_own, “.ReagentsPeer::REA_VENDORID.” AS rea_vendorid_R, “.ReagentsPeer::REA_ID .” AS rea_id_old, “.ReagentsPeer::REA_VENDORID.” AS rea_vendorid, “.ReagentsPeer::REA_USRID.” AS rea_usrid, “.ReagentsPeer::REA_TYPEID.” AS rea_typeid, “.ReagentsPeer::REA_NOOFCOMMENTS.” AS rea_no_comments, “.ReagentsPeer::REA_AVGRATING.” AS rea_avgrating, count(*) AS reaCount, (SELECT COUNT( “.ReagentRatingsPeer::RER_ID.” ) FROM “.ReagentRatingsPeer::TABLE_NAME.” WHERE “.ReagentRatingsPeer::RER_VENDORID.” = rea_vendorid_R AND “.ReagentRatingsPeer::RER_CATALOGUEID.” = rea_catalogueid_R ) AS ratingCount, ( SELECT “.ReagentsPeer::REA_NAME.” FROM “.ReagentsPeer::TABLE_NAME.” WHERE “.ReagentsPeer::REA_VENDORID.” = rea_vendorid_R AND “.ReagentsPeer::REA_CATALOGUEID.” = rea_catalogueid_R AND “.ReagentsPeer::REA_PRIVATE.” = ‘0’ GROUP BY “.ReagentsPeer::REA_NAME.” ORDER BY COUNT(*) DESC, “.ReagentsPeer::REA_NAME.” ASC, reagent_own DESC LIMIT 1 ) AS rea_name, ( SELECT “.ReagentsPeer::REA_ID.” FROM “.ReagentsPeer::TABLE_NAME.” WHERE “.ReagentsPeer::REA_VENDORID.” = rea_vendorid_R AND “.ReagentsPeer::REA_CATALOGUEID.” = rea_catalogueid_R AND “.ReagentsPeer::REA_PRIVATE.” = ‘0’ GROUP BY “.ReagentsPeer::REA_NAME.” ORDER BY COUNT(*) DESC, “.ReagentsPeer::REA_NAME.” ASC, reagent_own DESC LIMIT 1 ) AS rea_id FROM “.ReagentsPeer::TABLE_NAME.” LEFT JOIN “.UserPeer::TABLE_NAME.”  ON (“.ReagentsPeer::REA_USRID.” = “.UserPeer::USR_ID.”)  WHERE 1 “;
$sqlQuery .= ” AND “.ReagentsPeer::REA_ENABLE_SELFRATINGCOMMENT.” = ‘1’ AND “.UserPeer::USR_COUNTRY.” = ‘”.$countryCode.”‘  AND “.ReagentsPeer::REA_PRIVATE.”=’0′ AND “.ReagentsPeer::REA_PRODUCTTYPE.”=’nonvendor’ AND “.ReagentsPeer::REA_AVGRATING.”<>” AND (“.ReagentsPeer::REA_NAME.” LIKE ‘%”.$txtSearch.”%’ OR “.ReagentsPeer::REA_NAME.” LIKE ‘%”.$txtSearchwithSpace.”%’ OR “.ReagentsPeer::REA_NAME.” LIKE ‘%”.$txtSearchwithoutSpace.”%’)  GROUP BY “.ReagentsPeer::REA_VENDORID.”, “.ReagentsPeer::REA_CATALOGUEID.’ ORDER BY ‘.ReagentsPeer::REA_AVGRATING.” DESC, ratingCount DESC ” ;

/* —————– FOR START SETTING THE CONNECTION OBJECT ——————- */
$con = sfContext::getInstance()->getDatabaseConnection(‘propel’);
$records = sfConfig::get(‘app_paging_perpagelist’);

$curPage = $this->getRequestParameter(‘pageNv’, 1);
$limit = $records;
//$limit = 2;

$startLimit = ($curPage – 1) * $limit;

$sqlQuery .= ” LIMIT “. $startLimit.”, “.$limit;

//echo $sqlQuery;

$objRslt = $con->executeQuery($sqlQuery);

$this->objRslt = $objRslt;

$strCountQuery = “SELECT FOUND_ROWS() as totRec”;
$rsCnt = $con->executeQuery($strCountQuery);
$rsCnt->next();
$this->totRec = $rsCnt->get(‘totRec’);

$pager = myGeneric::getCustomPagerArray($curPage, $limit, $this->totRec);

$this->pager = $pager;
$this->objRslt = $objRslt;
$this->currentPage = $curPage;

if ($curPage && $this->endodedURL) {
$tmpURL = base64_decode($this->endodedURL);
$tmpURL = unserialize($tmpURL);
//print_r(‘<pre>’);
//print_r($tmpURL);
//print_r(‘</pre>’);
$tmpURL[‘pageNv’]=$curPage;
$tmpURL[‘pageV’]=$this->getRequestParameter(‘pageV’, 1);
$this->endodedURL = base64_encode(serialize($tmpURL));
}
if($this->endodedURL) $extrVar .=’&endodedURL=’.$this->endodedURL;

//print_r($pager);
$this->objQtzReagent = $objQtzReagent;

$this->extrVar = $extrVar;