×
Clear all filters including search bar
Valeri Tandilashvili's Personal Professional Blog
VALUES
clause we list the values in the same order as the columns are defined in the first clauseINSERT INTO `students` (
`id`,
`first_name`,
`last_name`,
`points`,
`mail`,
`santa_id`
)
VALUES (
NULL,
'დავით',
'ბერიძე',
'54',
'david@gmail.com',
'10'
);
Inserts several rows with one INSERT statementINSERT INTO `students` (
`id`,
`first_name`,
`last_name`,
`points`,
`mail`,
`santa_id`
)
VALUES
(NULL, 'დავით', 'ბერიძე', '54', 'david@gmail.com', '10'),
(NULL, 'გელა', 'თავაძე', '54', 'david@gmail.com', '10'),
(NULL, 'თამარ', 'დავითაშვილი', '54', 'david@gmail.com', '10')
;
We can exclude nullable fields and pass only the necessary fieldsINSERT INTO `students` (
`first_name`,
`last_name`,
`points`
)
VALUES (
'დავით',
'ბერიძე',
'54'
)
INSERT & SELECT statementINSERT INTO `students` (`first_name`, `last_name`, `points`)
SELECT first_name, last_name, points * 1.2 FROM students WHERE id = 3
We can use sub-query
in INSERT statement.
Before inserting the record, sub-query
gets gender_id
based on the provided gender nameINSERT INTO students (
first_name,
last_name,
points,
gender_id
)
VALUES (
'ილია',
'დავითაშვილი',
'84',
(SELECT id FROM genders WHERE name = 'Male')
)
```INSERT INTO `t_cal_mention` VALUES
(1, 4, 1426, '0000-00-00 00:00:00', 0)
The insert query will produce the following MySQL errorError Code: 1292. Incorrect datetime value: '0000-00-00 00:00:00' for column inserted_at at row 14
Row with date value '0000-00-00' is not allowedINSERT INTO `t_design` VALUES (5,0,'წმ. დიდმოწამე მარინე','წმ. დიდმოწამე მარინე','წმ. დიდმოწამე მარინე','oi8io_104355.jpg','0000-00-00','')
The insert query will produce the following MySQL errorError Code: 1292. Incorrect date value: '0000-00-00' for column 'date' at row 14
...upstream sent too big header while reading response header from upstream...
Is fixed by adding these lines:fastcgi_buffers 8 16k; # increase the buffer size for PHP-FTP
fastcgi_buffer_size 32k; # increase the buffer size for PHP-FTP
fastcgi_connect_timeout 60;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
To the site's configuration file:server {
listen 80;
server_name pm.use.ge;
root /var/www/pm.use.ge/public_html;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params; > deny all;
}
}
So that the final configuration file looks like this:server {
listen 80;
server_name pm.use.ge;
root /var/www/pm.use.ge/public_html;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_buffers 8 16k; # increase the buffer size for PHP-FTP
fastcgi_buffer_size 32k; # increase the buffer size for PHP-FTP
fastcgi_connect_timeout 60;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
include fastcgi_params; > deny all;
}
}
pm.test("Body is correct", function () {
pm.response.to.have.body('{"status":{"code":400,"text":"Mobile Number is required"}}');
});
The response JSON{
"status": {
"code": 400,
"text": "Mobile Number is required"
}
}
The test returns true
because the text passed to the test is the same as the response JSONMobile Number
pm.test("Body matches string", function () {
pm.expect(pm.response.text()).to.include("Mobile Number");
});
The response JSON{
"status": {
"code": 400,
"text": "Mobile Number is required"
}
}
forget
about test.php
that was tracked but is now in .gitignore
git rm --cached test.php
The command makes Git forget
about all files under docs
directory that was tracked but is now in .gitignore
git rm -r --cached docs/
getsebool -a | grep httpd
Setting to enable to connect to FB to another server:setsebool -P httpd_can_network_connect_db 1
address.xml
into an XML DOM object.
Then extracts contact
information using JavaScript
<!DOCTYPE html>
<html>
<body>
<h1>TutorialsPoint DOM example </h1>
<div>
<b>Name:</b> <span id = "name"></span><br>
<b>Company:</b> <span id = "company"></span><br>
<b>Phone:</b> <span id = "phone"></span>
</div>
<script>
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
// else
// {// code for IE6, IE5
// xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
// }
xmlhttp.open("GET","address.xml",false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
document.getElementById("name").innerHTML = xmlDoc.getElementsByTagName("name")[0].childNodes[0].nodeValue;
document.getElementById("company").innerHTML = xmlDoc.getElementsByTagName("company")[0].childNodes[0].nodeValue;
document.getElementById("phone").innerHTML = xmlDoc.getElementsByTagName("phone")[0].childNodes[0].nodeValue;
</script>
</body>
</html>
address.xml
file content<?xml version = "1.0"?>
<contact>
<name>Tanmay Patil</name>
<company>TutorialsPoint</company>
<phone>(011) 123-4567</phone>
</contact>
<select>
element using document.createElement
method and fills with JSON arrayoptionArray = [
"daily",
"weekly",
"biweekly",
"monthly"
];
// Creates <select> element
let selector = document.createElement('select');
for(let option in optionArray) {
let value = optionArray[option];
// Creates <option> element for <select>
let newOption = document.createElement("option");
newOption.value = value;
newOption.innerHTML = value;
selector.options.add(newOption);
}
// Adds the <select> element into the document object
document.body.appendChild(selector);
<script>
element and fills with the JSON
retrieved from a server<script>
var obj, dbParam, xmlhttp, myObj, x, txt = "";
obj = { table: "customers", limit: 20 };
dbParam = JSON.stringify(obj);
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myObj = JSON.parse(this.responseText);
txt += "<select>"
for (x in myObj) {
txt += "<option>" + myObj[x].name;
}
txt += "</select>"
document.write(txt);
}
};
xmlhttp.open("POST", "json_demo_html_table.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("x=" + dbParam);
</script>