php - Sql string query not working -
i'm building sql queries in yii framework.
so far working fine until need compare variable string.
here function query:
public function countcanceled() { $week = person_event::model()->weekbydate(); $week_id = $week->id; $datalogin = mysqli_connect( /*connect working fine*/); $sql = "select id tbl_event week_id=$week_id , status_id='canceled'"; $query = mysqli_query($datalogin, $sql); $numrows = mysqli_num_rows($query); return $numrows; }
now , have 1 event canceled status, , ran same query in mysql server , result of 1 given, why in yii doesn't work? (tried switch "=" "like" , made no difference)
p.s yes , in particular case use built in yii's queries , have other, more complicated queries need compare string. thanks, mark.
what type of status_id if char data space padded full length. can change varchar , compare. , can use 'canceled%'
ps. sorry not have enough reputation comment...:(
best regards, nebojsa
Comments
Post a Comment