Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
CREATE TABLE LIKE
Creates
sdt_prices_unique
table with exactly the same structure as
sdt_prices
table has
CREATE TABLE sdt_prices_unique LIKE sdt_prices
by Valeri Tandilashvili
3 years ago
0
MySQL
1
Make existing column UNIQUE
Makes
columnname
column UNIQUE
ALTER TABLE dbname.tablename
ADD UNIQUE (columnname)
by Valeri Tandilashvili
3 years ago
0
MySQL
1
INSERT IGNORE INTO
Inserts all rows, ignores rows with
Duplicate key
error
INSERT IGNORE INTO dbname.prices_unique
SELECT * FROM dbname.prices
by Valeri Tandilashvili
3 years ago
0
MySQL
1
Sort array of arrays by sub-array values
We need to sort the array by
price
value
$inventory = array(

   array("type"=>"fruit", "price"=>3.50),
   array("type"=>"milk", "price"=>2.90),
   array("type"=>"pork", "price"=>5.43),

);
The solution is to use
array_multisort
function
$price = array();
foreach ($inventory as $key => $row)
{
    $price[$key] = $row['price'];
}
array_multisort($price, SORT_DESC, $inventory);
In PHP 5.5 or later
array_column
function can be used
$price = array_column($inventory, 'price');

array_multisort($price, SORT_DESC, $inventory);
by Valeri Tandilashvili
3 years ago
0
PHP
0
Lost connection to MySQL server during query
When trying to import database the following problem occurred:
ERROR 2013 (HY000) at line 430: Lost connection to MySQL server during query
Solution to the problem was to increase connection timeout variable by running to following query:
SET GLOBAL connect_timeout = 10;
by Valeri Tandilashvili
3 years ago
0
MySQL
1
UTF-8 Unicode problem while json_encode()
JSON_UNESCAPED_UNICODE Json:
"[{"name":"additional[text][9]","value":"\u10e1 \u10d3\u10d0\u10e1\u10d0\u10d1\u10e3\u10d7\u10d4\u10d1\u10d0 (Judgement process"},{"name":"additional[text][3]","value":"version"}]"
If our json contains something like this
\u10d3\u10d0\u10e1\u10d0\u10d1\u10e3\u10d7\u10d4\u10d1\u10d0
we have UTF-8 unicode problem.
JSON_UNESCAPED_UNICODE
fixes this problem, so we can encode json like this
json_encode($request->field_data, JSON_UNESCAPED_UNICODE)
by Luka Tatarishvili
3 years ago
0
JSON
Laravel
DBquery
0
If we have a table with a seeder and we want to add a foreign key to a column it must contain the correct id value or it can't be empty.
You can't use a value that doesn't belong to any entity in the other table nor delete one entity who has its ID in some other foreign_key in some other entity
by Luka Tatarishvili
3 years ago
0
Laravel
database
0
set identifier name to foreign key
When we have an Identifier name on the foreign key is a too-long error we can set name ourselves. Note:
Max foreign char size is 64
Example: Before:
$table->foreign('risk_project_id',)->references('id')->on('business_risk_projects')->onDelete('restrict');
Solution:
$table->foreign('risk_project_id', 
'business_rp_has_responsible_persons_risk_project_id_foreign'
)->references('id')->on('business_risk_projects')->onDelete('restrict');
Just add a second parameter to the foreign() method with the name of the key 
by Luka Tatarishvili
3 years ago
0
Laravel
0
Include .blade.php file
Includes
.blade.php
file located at:
\resources\views\external\calculator
<div class="container">
    
    @include('external.calculator.panel')

</div>
by Valeri Tandilashvili
3 years ago
0
Laravel
0
Makes the array member stay filled after backend validation is failed
Makes the array member stay filled if the form is not successfully validated on the backend:
$item_presale_tokens = old('values.0');
$item_liquidity_tokens = old('values.1');
Form html looks like this:
<div class="form-group d-flex border-bottom-0">
    <div class="form-equal-inputs">
        <input type="number" step="1" min="1" value="{{ $item_presale_tokens }}" class="form-control {{ $errors->has('values.0') ? 'is-invalid' : '' }}" name="values[]" placeholder="Value"/>
    </div>
    

</div>

<div class="form-group d-flex border-bottom-0">
    <div class="form-equal-inputs">
        <input type="number" step="1" min="1" value="{{ $item_liquidity_tokens }}" class="form-control {{ $errors->has('values.1') ? 'is-invalid' : '' }}" name="values[]" placeholder="Value"/>
    </div>
</div>
by Valeri Tandilashvili
3 years ago
0
Laravel
0
Results: 1578