What does the following line mean, particularly the operator .=
?
$query .= "UPDATE authors SET author=LOWER(author) WHERE id=2;";
in the code
$conn = pg_pconnect("dbname=publisher");
// these statements will be executed as one transaction
$query = "UPDATE authors SET author=UPPER(author) WHERE id=1;";
$query .= "UPDATE authors SET author=LOWER(author) WHERE id=2;";
pg_query($conn, $query);
?>
It seems to make some sort of array such that the last command processes first the first query and then the second.
Answer
This is the concatenate assignment operator. It will concatenate or add to the end of the string. So:
$a = "Hi!";
$a .= " I";
$a .= " love";
$a .= " StackOverflow";
$a .= " a";
$a .= " lot";
echo $a; // echos "Hi! I love StackOverflow a lot"
In your case
$query = "UPDATE authors SET author=UPPER(author) WHERE id=1;";
$query .= "UPDATE authors SET author=LOWER(author) WHERE id=2;";
echo $query;
/* echos "UPDATE authors SET author=UPPER(author) WHERE id=1; UPDATE authors SET author=LOWER(author) WHERE id=2; */
No comments:
Post a Comment