snipt

Ctrl+h for KB shortcuts

Text only

Transactions en Laravel 3

1
2
3
4
5
DB::transaction(function(){
    DB::query($sql_portada);
    DB::query($sql_404);
    DB::query($sql_generos);
});
https://snipt.net/embed/6a2db37f27fe3d4e036201e72b1a107e/
/raw/6a2db37f27fe3d4e036201e72b1a107e/
6a2db37f27fe3d4e036201e72b1a107e
text
Text only
5
2019-08-12T00:04:04
True
False
False
Dec 11, 2013 at 03:45 PM
/api/public/snipt/99902/
transactions-en-laravel-3
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>DB::transaction(function(){ </span><span id="L-2"><a name="L-2"></a> DB::query($sql_portada); </span><span id="L-3"><a name="L-3"></a> DB::query($sql_404); </span><span id="L-4"><a name="L-4"></a> DB::query($sql_generos); </span><span id="L-5"><a name="L-5"></a>}); </span></pre></div> </td></tr></table>
laravel, pdo, php

Text only

Ejecutar un PHP en vez de un JS

1
2
3
4
5
RewriteEngine on

RewriteCond %{REQUEST_URI} ^/magic.js
RewriteCond %{QUERY_STRING} ((.*))?
RewriteRule (.*)  magic.php?%2 [L]
https://snipt.net/embed/47146a4e3fbda964500551cfd323c087/
/raw/47146a4e3fbda964500551cfd323c087/
47146a4e3fbda964500551cfd323c087
text
Text only
5
2019-08-13T16:19:19
True
False
False
/api/public/snipt/52883/
ejecutar-un-php-en-vez-de-un-js
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>RewriteEngine on </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>RewriteCond %{REQUEST_URI} ^/magic.js </span><span id="L-4"><a name="L-4"></a>RewriteCond %{QUERY_STRING} ((.*))? </span><span id="L-5"><a name="L-5"></a>RewriteRule (.*) magic.php?%2 [L] </span></pre></div> </td></tr></table>
apache, htaccess, js, php, vhost

PHP

reemplaza los \n y \r con tags <br />

1
2
3
4
<?php
    function nl2br($text) { 
        return strtr($text, array("\r\n" => '<br />', "\r" => '<br />', "\n" => '<br />')); 
    } 
https://snipt.net/embed/d64a5d2028d83cea00afdfebf78cf3d1/
/raw/d64a5d2028d83cea00afdfebf78cf3d1/
d64a5d2028d83cea00afdfebf78cf3d1
php
PHP
4
2019-07-12T14:45:43
True
False
False
Sep 19, 2012 at 12:01 PM
/api/public/snipt/30553/
reemplaza-los-n-y-r-con-tags-br
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">function</span> <span class="nf">nl2br</span><span class="p">(</span><span class="nv">$text</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">return</span> <span class="nb">strtr</span><span class="p">(</span><span class="nv">$text</span><span class="p">,</span> <span class="k">array</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\r\n</span><span class="s2">&quot;</span> <span class="o">=&gt;</span> <span class="s1">&#39;&lt;br /&gt;&#39;</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\r</span><span class="s2">&quot;</span> <span class="o">=&gt;</span> <span class="s1">&#39;&lt;br /&gt;&#39;</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">=&gt;</span> <span class="s1">&#39;&lt;br /&gt;&#39;</span><span class="p">));</span> </span><span id="L-4"><a name="L-4"></a> <span class="p">}</span> </span></pre></div> </td></tr></table>
php