How to apply or condition for mysql query in symfony

$cs = new Criteria();
$criterion = $cs->getNewCriterion(HfArticlesPeer::AR_DESCRIPTION,’%’.$searchText.’%’,Criteria::LIKE);
$criterion->addOr($cs->getNewCriterion(HfArticlesPeer::AR_TITLE,’%’.$searchText.’%’,Criteria::LIKE));
$criterion1 = $cs->getNewCriterion(HfArticlesPeer::AR_STATUS,’ARCHIVE’,Criteria::EQUAL);
$criterion1->addOr($cs->getNewCriterion(HfArticlesPeer::AR_STATUS,’PUBLISHED’,Criteria::EQUAL));
$cs->add($criterion1);
$cs->add($criterion);
$cs->add(HfArticlesPeer::AR_CATEGORY ,InsuranceCatId,Criteria::EQUAL);
$searchResInsuranceArticle = HfArticlesPeer::doSelect($cs);

No connection params set for propel

When you are using symfony framework , and when you get the error as

“No connection params set for propel” ,Do the following changes .

In config /databases.yml file

Replace

all:
propel:
class: sfPropelDatabase
param:
datasource: symfony
dsn: mysql://root:@localhost/mywebsite

with

all:
propel:
class: sfPropelDatabase
param:
phptype: mysql
host: localhost
database: databaseName
username: root
password: password
dsn: mysql://root:password@localhost/databaseName
datasource: propel

In config/propel.ini

Replace

propel.targetPackage = lib.model
propel.packageObjectModel = true
propel.project = projectFolderName
propel.database = mysql
propel.database.createUrl = mysql://root:password@localhost/databaseName
propel.database.url = mysql://root:password@localhost/databaseName

with

propel.targetPackage = lib.model
propel.packageObjectModel = true
propel.project = projectFolderName
propel.database = mysql
propel.database.createUrl = mysql://localhost/
propel.database.url = mysql://root:password@localhost/databaseName

This will rectify your problem.

how to create html element dynamically in javascript

var itemManCnt=2;
function addMoreHomeImage()
{
if(itemManCnt==6)
{
alert(“You can upload only 5 files”);
return false;

}
var parentObj=document.getElementById(‘FileElementItem’);
var divClrBoth = document.createElement(“div”);
divClrBoth.setAttribute(“class”,”ClrBoth”);
divClrBoth.setAttribute(“id”,itemManCnt);

var divClrSelect = document.createElement(“div”);
divClrSelect.setAttribute(“class”,”Select”);

var file= document.createElement(“input”);
file.setAttribute(“type”,”file”);
file.setAttribute(“id”,”InsuranceHomeImage”+itemManCnt);
file.setAttribute(“name”,”InsuranceHomeImage”+itemManCnt);
divClrSelect.appendChild(file);

var divRemove= document.createElement(“div”);
divRemove.setAttribute(“class”,”AddNew”);

var divRemoveLink = document.createElement(“a”);
divRemoveLink.setAttribute(‘onclick’,’deleteHomeImage(‘+itemManCnt+’)’);itemManCnt++;
divRemoveLink.innerHTML=’Remove’;
divRemove.appendChild(divRemoveLink);

divClrBoth.appendChild(divClrSelect);
divClrBoth.appendChild(divRemove);

parentObj.appendChild(divClrBoth);
}
function deleteHomeImage(iEle)
{
var parentObj=document.getElementById(‘FileElementItem’);
var olddiv = document.getElementById(iEle);
–itemManCnt;
parentObj.removeChild(olddiv);
}

Implementation example

<div id=”FileElementItem” class=”FileElement”>
<div class=”ClrBoth”>
<div class=”Select”>
<input type=”file” name=”InsuranceHomeImage1″ id=”InsuranceHomeImage1″>
</div>
<div class=”AddNew”>
<a onclick=”addMoreHomeImage()”>Add New</a>
</div>
</div>
</div>

To calculate date difference between two given dates

function timeDifference(startDate,endDate)
{

date1 = startDate;
date2 = endDate;

laterdate = date1.split(“-“);
laterY=laterdate[0];
laterM=laterdate[1];
laterD=laterdate[2];

earlierdate = date2.split(“-“);
earlierY=earlierdate[0];
earlierM=earlierdate[1];
earlierD=earlierdate[2];

var laterdate = new Date(laterY,laterM,laterD);
var earlierdate = new Date(earlierY,earlierM,earlierD);

var difference = laterdate.getTime() – earlierdate.getTime();

var daysDifference = Math.floor(difference/1000/60/60/24);
difference -= daysDifference*1000*60*60*24
var hoursDifference = Math.floor(difference/1000/60/60);
difference -= hoursDifference*1000*60*60
var minutesDifference = Math.floor(difference/1000/60);
difference -= minutesDifference*1000*60
var secondsDifference = Math.floor(difference/1000);

return daysDifference;

}

validate email address

function echeck(str) {

var at=”@”
var dot=”.”
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){
return false
}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
return false
}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
return false
}

if (str.indexOf(at,(lat+1))!=-1){
return false
}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
return false
}

if (str.indexOf(dot,(lat+2))==-1){
return false
}

if (str.indexOf(” “)!=-1){
return false
}

return true
}