protected function enquote($str) { $singleQuoted = "'" . addcslashes($str, "\\'") . "'"; $doubleQuoted = '"' . addcslashes($str, '\\"') . '"'; return strlen($singleQuoted) < strlen($doubleQuoted) ? $singleQuoted : $doubleQuoted; }