Codeigniter:使用预准备语句删除查询

I'm not sure if this is a codeigniter thing or specifically a mysqli thing.

In my model class I'm trying to delete using 2 WHERE arguments:

$query = "DELETE FROM users WHERE user_id = ? AND company_id = ?";
$result = $this->db->query( $query, $user_id, '1' );

Error message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? AND company_id = ?' at line 1

Any ideas?

I recommend you to use 'active record'

$this->db->where('user_id', $user_id);
$this->db->where('company_id', 1);
$this->db->delete('users'); 

https://ellislab.com/codeigniter/user-guide/database/active_record.html

using active record is ok but using native SQL takes less resources , I quote:

Note: If you intend to write your own queries you can disable active record in your database config file, allowing the core database library and adapter to utilize fewer resources.

source : https://ellislab.com/codeigniter/user-guide/database/active_record.html

here is my two lines

$query_string = "DELETE FROM users WHERE user_id =".$user_id." AND company_id = 1";
$query= $this->db->query($query_string); // will return True if SUCCESS