mysql -> mysqli

Bring Castiel's mysqli changes.