snipt

Ctrl+h for KB shortcuts

PHP

Basic PHP - Show Errors

error_reporting(E_ALL);
ini_set("display_errors", 1); 
https://snipt.net/embed/3b9c680001e7fb974bab88b941c266af/
/raw/3b9c680001e7fb974bab88b941c266af/
3b9c680001e7fb974bab88b941c266af
php
PHP
2
2019-08-20T20:46:24
True
False
False
/api/public/snipt/22918/
basic-php-show-errors
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">error_reporting(E_ALL);</span> </span><span id="L-2"><a name="L-2"></a><span class="x">ini_set(&quot;display_errors&quot;, 1); </span> </span></pre></div> </td></tr></table>
errors, ini, php

MySQL

Import CSV data into mysql table

1
2
3
4
5
6
7
8
load data infile '/var/lib/mysql/your_db/yourcsv.csv' into table magento_orders
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
// if csv exported from linux - use lines terminated by '\n'
// if csv exported from windows use lines terminated by '\r\n'
// if csv exported from mac - use lines terminated by '\r'
(OrderDate,ShippingState,ShippingStateName,ShippingCountry,ShippingCountryName,ItemName,ItemOptions,ItemQtyOrdered)
https://snipt.net/embed/38a111f635185e6302190f57cd525175/
/raw/38a111f635185e6302190f57cd525175/
38a111f635185e6302190f57cd525175
mysql
MySQL
8
2019-08-09T21:01:34
True
False
False
/api/public/snipt/17582/
import-csv-data-into-mysql-table
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">load</span> <span class="n">data</span> <span class="k">infile</span> <span class="s1">&#39;/var/lib/mysql/your_db/yourcsv.csv&#39;</span> <span class="k">into</span> <span class="k">table</span> <span class="n">magento_orders</span> </span><span id="L-2"><a name="L-2"></a><span class="n">fields</span> <span class="k">terminated</span> <span class="k">by</span> <span class="s1">&#39;,&#39;</span> </span><span id="L-3"><a name="L-3"></a><span class="k">enclosed</span> <span class="k">by</span> <span class="s1">&#39;&quot;&#39;</span> </span><span id="L-4"><a name="L-4"></a><span class="k">lines</span> <span class="k">terminated</span> <span class="k">by</span> <span class="s1">&#39;\n&#39;</span> </span><span id="L-5"><a name="L-5"></a><span class="o">//</span> <span class="k">if</span> <span class="n">csv</span> <span class="n">exported</span> <span class="k">from</span> <span class="n">linux</span> <span class="o">-</span> <span class="k">use</span> <span class="k">lines</span> <span class="k">terminated</span> <span class="k">by</span> <span class="s1">&#39;\n&#39;</span> </span><span id="L-6"><a name="L-6"></a><span class="o">//</span> <span class="k">if</span> <span class="n">csv</span> <span class="n">exported</span> <span class="k">from</span> <span class="n">windows</span> <span class="k">use</span> <span class="k">lines</span> <span class="k">terminated</span> <span class="k">by</span> <span class="s1">&#39;\r\n&#39;</span> </span><span id="L-7"><a name="L-7"></a><span class="o">//</span> <span class="k">if</span> <span class="n">csv</span> <span class="n">exported</span> <span class="k">from</span> <span class="n">mac</span> <span class="o">-</span> <span class="k">use</span> <span class="k">lines</span> <span class="k">terminated</span> <span class="k">by</span> <span class="s1">&#39;\r&#39;</span> </span><span id="L-8"><a name="L-8"></a><span class="p">(</span><span class="n">OrderDate</span><span class="p">,</span><span class="n">ShippingState</span><span class="p">,</span><span class="n">ShippingStateName</span><span class="p">,</span><span class="n">ShippingCountry</span><span class="p">,</span><span class="n">ShippingCountryName</span><span class="p">,</span><span class="n">ItemName</span><span class="p">,</span><span class="n">ItemOptions</span><span class="p">,</span><span class="n">ItemQtyOrdered</span><span class="p">)</span> </span></pre></div> </td></tr></table>
csv, data, import, mysql

Text only

Get Basic Product Info From Magento DB

1
2
3
4
5
6
7
SELECT e.entity_id AS product_id, var.value AS product_name
FROM catalog_product_entity e, eav_attribute eav, catalog_product_entity_varchar var
WHERE 
   e.entity_type_id = eav.entity_type_id 
   AND eav.attribute_code = 'name' 
   AND eav.attribute_id = var.attribute_id
   AND var.entity_id = e.entity_id
https://snipt.net/embed/af58e82d413d6e3d0792d327c49dcf63/
/raw/af58e82d413d6e3d0792d327c49dcf63/
af58e82d413d6e3d0792d327c49dcf63
text
Text only
8
2019-08-23T05:03:22
True
False
False
/api/public/snipt/17576/
get-basic-product-info-from-magento-db
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>SELECT e.entity_id AS product_id, var.value AS product_name </span><span id="L-2"><a name="L-2"></a>FROM catalog_product_entity e, eav_attribute eav, catalog_product_entity_varchar var </span><span id="L-3"><a name="L-3"></a>WHERE </span><span id="L-4"><a name="L-4"></a> e.entity_type_id = eav.entity_type_id </span><span id="L-5"><a name="L-5"></a> AND eav.attribute_code = &#39;name&#39; </span><span id="L-6"><a name="L-6"></a> AND eav.attribute_id = var.attribute_id </span><span id="L-7"><a name="L-7"></a> AND var.entity_id = e.entity_id </span></pre></div> </td></tr></table>
magento, mysql, sql