php code consolidation
I was troubleshooting some code and ended up with this:
$url=$this->_protected_arr['f3b'];
$title=$this->_protected_arr['f3a'];
$email=$_SESSION['email'];
database::query("INSERT INTO bo VALUES ('$title','$url','','$email')");
I think that it should be abe开发者_如何转开发l to get rid of $url, $title, and $email and just insert their values directly into the query. How do I write this in a single statement?
Like this:
database::query("INSERT INTO bo VALUES ('{$this->_protected_arr[f3b]}', '{$this->_protected_arr[f3a]}', '', '$_SESSION[email]')");
Be sure that everything is properly escaped for the SQL query.
database::query("INSERT INTO bo VALUES ('"
. $this->_protected_arr[f3b] . "', '"
. $this->_protected_arr[f3a] . "', '', '"
. $_SESSION[email]."')");
精彩评论