I find I need to write queries without using CI’s active record frequently for example:
$query = "INSERT INTO votes (userid, itemId) VALUES ({$userId},{$itemId})
ON DUPLICATE KEY UPDATE weight = {$vote}";
$query = $this->db->query($query);
Should I be worried about performance or security loss because of this?
You may use Query Bindings, you can enjoy flexibility with security. But you my not be able switch database in future.
http://codeigniter.com/user_guide/database/queries.html
Example: