Sql String Query Not Working In Yii

I’m building some Sql queries.

So far all is working fine up until I need to compare a variable to a string.

Here is my function with the query:


  public function countCanceled() 

    	{

    		$week=Person_Event::model()->weekByDate();

    	$week_id=$week->id;

    		$datalogin=mysqli_connect(//connect is working fine);

    		$sql ="SELECT id

    			   FROM tbl_event

    			   WHERE week_id=8 AND status_id='canceled'

    			   "; 

    	$query = mysqli_query($datalogin, $sql);

    	$numrows = mysqli_num_rows($query);

    	return $numrows;

    	}

Now , I clearly have one event with canceled status, and I ran the same query in MySql server and the result of 1 was given, so why in Yii it doesn’t work?

(tried to switch "=" with "like" , made no difference)

edited: yes , I can use Yii’s query here , but I have more complicated queries where I still need to compare string

Thanks,

Mark.

is ‘status_id’ REALLY a string column? ‘*_id’ suggests it is rather just FK to another table…

Yes. The name is misleading. It is a VARCHAR.

Any ideas?

seems weird that Yii could influence the way dbms works. It is simply impossible.

The problem must be somewhere else. Try to debug and echo everything step by step. Check what’s in $numrows, etc…