const firstName = 'Giorgi';
const job = 'Doctor';
const birthdayYear = 1991;
const currentDate = new Date();
const currentYear = currentDate.getFullYear()
//same results but different syntax
const giorgisInfo = "I'm " + firstName + ', a ' + (currentYear - birthdayYear) + ' year old ' + job + '!';
console.log(giorgisInfo)
//----------------
const giorgisInfoNew = `I'm ${firstName}, a ${currentYear - birthdayYear} year old ${job}!`
console.log(giorgisInfoNew)
console.log('---- OR ----');
console. log(3 || 'Jonas'); //result:3
console.log('' || 'Jonas'); //result:Jonas
console.log(true || 0); //result:true
console.log(undefined || null); //result:null
console.log(undefined || 0 || '' || 'Hello' || 23 || null); //result:Hello
console.log('---- AND ----');
console. log(0 && 'Jonas'); //result:0
console. log(7 && 'Jonas'); //result:Jonas
console.log('Hello' && 23 && null && 'Jonas'); //result:null
SELECT table_schema "database", sum(data_length + index_length)/1024/1024/1024 "size in GB"
FROM information_schema.TABLES GROUP BY table_schema;
The following query can show the size (MB) of all the database in a table view :
SELECT table_schema 'database', ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM information_schema.tables
GROUP BY table_schema;
The following query can show only the size of a specific database:
SELECT table_schema,
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM information_schema.tables WHERE table_schema='DB_NAME'
GROUP BY table_schema ;
The following query can show total tables, the total table row, DB size of a specific database:
SELECT TABLE_SCHEMA AS DB_Name, count(TABLE_SCHEMA) AS Total_Tables,
SUM(TABLE_ROWS) AS Total_Tables_Row,
ROUND(sum(data_length + index_length)/1024/1024) AS "DB Size (MB)", ROUND(sum( data_free )/ 1024 / 1024) AS "Free Space (MB)"
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'DB_NAME'
GROUP BY TABLE_SCHEMA ;
SELECT
COUNT(*)
FROM
customers;
MySQL row count of two or more tables:
SELECT
'customers' tablename,
COUNT(*) rows
FROM
customers
UNION
SELECT
'orders' tablename,
COUNT(*) rows
FROM
orders;
$users
array according to "score"
value
$users = array(
[
'id' => 1,
'name' => 'vighac tipovichi',
'score' => 90
],
[
'id' => 2,
'name' => 'sxva tipson',
'score' => 100
],
);
__________________________________________
1st method is using this custom function:
array_sort($users, 'score', SORT_DESC)
function array_sort($array, $on, $order=SORT_ASC){
$new_array = array();
$sortable_array = array();
if (count($array) > 0) {
foreach ($array as $k => $v) {
if (is_array($v)) {
foreach ($v as $k2 => $v2) {
if ($k2 == $on) {
$sortable_array[$k] = $v2;
}
}
} else {
$sortable_array[$k] = $v;
}
}
switch ($order) {
case SORT_ASC:
asort($sortable_array);
break;
case SORT_DESC:
arsort($sortable_array);
break;
}
foreach ($sortable_array as $k => $v) {
$new_array[$k] = $array[$k];
}
}
return $new_array;
}
__________________________________________
2nd method is by using usort
built-in function which allows us to use "user defined" callback/function to sort array:
1.either by declaring another function dedicated to sort array as you wish
function custom_sort_users($a, $b) {
if ($a['score'] == $b['score']) {
return 0;
}
return ($a['score'] > $b['score']) ? -1 : 1;
}
usort($users, "custom_sort_users");
2.or using callback:
usort($users, function($a, $b){
if ($a['score'] == $b['score']) {
return 0;
}
return ($a['score'] > $b['score']) ? -1 : 1;
});
sql.zip
file to the location /var/www/
of use.ge
server using root
user scp sql.zip root@use.ge:/var/www/
We can use full path for the file that we want to movescp /var/www/sql.zip root@use.ge:/var/www/
We can also use an IP address (instead of domain name) to specify the server that we want the file to move toscp /var/www/sql.zip root@167.172.187.21:/var/www/
After the command execution the user is required to enter password of root
user