Answer the question
In order to leave comments, you need to log in
How to understand the meaning of this line?
Can someone help me parse the meaning of this string
if /bin/ping -c 2 8.8.8.8 > /dev/null 2> /dev/null
/dev/null 2> /dev/null
Answer the question
In order to leave comments, you need to log in
each command returns a return code upon completion.
for if it is important not to compare something with something, but the return code of the command, which is 0 - success, not zero - error.
therefore if [ A == B ]
- this is not a comparison, but the execution of a command [ ]
, so here if ping
it is not a comparison, but the execution of a command ping
and getting its return code
> /dev/null 2> /dev/null
>
- redirecting stdout output to zero
2>
redirecting stderr output to zero
This is to display the command did not output anything - neither the main output nor the
ps error, you can see the return code through the $ variable?
ping -c 1 google.com
echo $?
ping -c 1 google.com1
echo $?
These are not mathematical operations. Read about streams and their operators in the bash. |
, >
, >>
, ;
etc.
Proper organization:
ID, SKU, ... , and other data common to all products with this SKU (for example, brand or brand ID (if brands are stored in a separate table); perhaps a link to the main image).
In general, the product itself is described here, as such.
variant_id, product_id, product options, balance.
Here are all combinations of possible options for a product, with a specific ID. As well as possible unique information for specific parameters (perhaps information that the product is promotional - let's say a 50% discount on super large sizes - here is a stock ID or something like that).
For example, if the options are size and color, then the table in this case is:
id, size, color, balance, and something else unique for this product variant (link to the image if the color is different, for example).
Of course, the combination of id + size + color fields must be unique in order to avoid duplicates.
If there are too many possible options for a product (and perhaps even the absence of some options and the presence of others), then you need to think about organizing a separate table of product options, but this is a topic for a separate discussion.
You have a table with a list of products. Let's say products. It contains columns with the article (id), name, brand, etc.
Add another table like sizes. It contains the name of the size (L, XL, etc.), the remainder, the product_id foreign key, which refers to the id in the products table.
And on the product page, you get from the database not only data from the products table by id, but also from the sizes table by the same products_id.
You need to create a second table and name it size. It has four columns:
id
Poduct_id
Size
Count
When entering data into the table, the size, product ID and quantity in stock are indicated.
1. It is possible to store in the database as an array, shared during the output, though then the 2nd point will not work.
2. You can make your own table with id + count for each property.
3. You can see how such things are implemented on large CMS IMs
4. You can generally apply a scientific approach and try to abstract from the semantic load by making functional dependencies and find the minimum coverage, although it may happen that at the stage of creating functional dependencies questions 1 and 2 are already resolved
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question