<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[PHP - OOP] Semplice classe OOP mi inchioda Firefox]]></title><description><![CDATA[<p dir="auto">Ciao,<br />
ho una classe che dovrebbe gestirmi la connessione al db ed eseguire delle semplici query. Al momento il codice l'ho strutturato come segue (notate il while commentato):</p>
<pre><code class="language-php">class Cnt{
        private $_result;
        const HOST = 'localhost';
        const USER = 'root';
        const PASS = '';
        const DB = 'prova';
        private $_cnt = FALSE;
        
        function __construct(){
            $this-&gt;_cnt = mysqli_connect(self::HOST, self::USER, self::PASS, self::DB);
            if(!$this-&gt;_cnt) die('Non connesso');
            mysqli_query($this-&gt;_cnt, "set names 'utf8'");
        }
    
    
    function query($query){
        $this-&gt;_result = mysqli_query($this-&gt;_cnt, $query);
        return $this-&gt;_result;
    }
    
    function __destruct(){
        mysqli_free_result($this-&gt;_result);
        mysqli_close($this-&gt;_cnt);
    }
}

$cnt = new Cnt;

$query = 'SELECT DISTINCT nome FROM utenti';
$a = $cnt-&gt;query($query);
$b = mysqli_fetch_assoc($a);
//while($b){
    echo $b['nome'];
//}
</code></pre>
<p dir="auto">La colonna "nome" utenti ha solo 4 record, di cui solo 1 duplicato. In teoria dovrebbe quindi restituirmi 3 nomi.<br />
Il problema sorge quando decommento il while. Il browser si blocca, la RAM va in saturazione e dopo un po' Firefox viene chiuso automaticamente con il classico avviso del crash dell'applicazione.<br />
Per carità... la classe sarà pure fatta male, ma non mi sembra sia un calcolo così complesso da aver bisogno di 4 GB di ram!<br />
Dov'è l'inghippo secondo voi?</p>
]]></description><link>https://dev.connect.gt/topic/210014/php-oop-semplice-classe-oop-mi-inchioda-firefox</link><generator>RSS for Node</generator><lastBuildDate>Fri, 27 Nov 2026 02:42:28 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/210014.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 17 Jan 2015 07:49:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [PHP - OOP] Semplice classe OOP mi inchioda Firefox on Sat, 17 Jan 2015 14:51:26 GMT]]></title><description><![CDATA[<p dir="auto">Eh... vedi che l'errore c'era?! <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/customizations/8dfea2c6-baa4-48ad-9022-ab237b734846-fumato5.gif?v=12b9555a9a1" class="not-responsive emoji emoji-customizations emoji--fumato" style="height:1.4em;width:auto;vertical-align:middle" title=":fumato:" alt="" /><br />
Sono quelle stupidaggini che fanno perdere le ore!<br />
Grazie, ora funziona.</p>
]]></description><link>https://dev.connect.gt/post/1185826</link><guid isPermaLink="true">https://dev.connect.gt/post/1185826</guid><dc:creator><![CDATA[oslino]]></dc:creator><pubDate>Sat, 17 Jan 2015 14:51:26 GMT</pubDate></item><item><title><![CDATA[Reply to [PHP - OOP] Semplice classe OOP mi inchioda Firefox on Sat, 17 Jan 2015 14:27:26 GMT]]></title><description><![CDATA[<p dir="auto">Non sò se hai editato ora il post o se non avevo visto io la parte finale prima, comunque adesso si vede benissimo che il ciclo è sbagliato, ed è infinito per cui hai un echo continuo di testo che porta al blocco del browser.<br />
Devi fare cosi:</p>
<pre><code>[COLOR=#007700][FONT=monospace]
[/FONT][/COLOR][COLOR=#FF8000][FONT=monospace]while([/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$b [/FONT][/COLOR][COLOR=#007700][FONT=monospace]= [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]mysqli_fetch_assoc[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$a[/FONT][/COLOR][COLOR=#007700][FONT=monospace])[/FONT][/COLOR][COLOR=#FF8000][FONT=monospace])
{
    [/FONT][/COLOR][COLOR=#007700][FONT=monospace]echo [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]$b[/FONT][/COLOR][COLOR=#007700][FONT=monospace][[/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]'nome'[/FONT][/COLOR][COLOR=#007700][FONT=monospace]];
[/FONT][/COLOR][COLOR=#FF8000][FONT=monospace]}
</code></pre>
]]></description><link>https://dev.connect.gt/post/1185840</link><guid isPermaLink="true">https://dev.connect.gt/post/1185840</guid><dc:creator><![CDATA[thedarkita]]></dc:creator><pubDate>Sat, 17 Jan 2015 14:27:26 GMT</pubDate></item><item><title><![CDATA[Reply to [PHP - OOP] Semplice classe OOP mi inchioda Firefox on Sat, 17 Jan 2015 14:23:44 GMT]]></title><description><![CDATA[<p dir="auto">Lo so... è per quello che non capisco il motivo del blocco. Tu vei qualche errore nel codice che potrebbe giustificarlo?</p>
]]></description><link>https://dev.connect.gt/post/1185825</link><guid isPermaLink="true">https://dev.connect.gt/post/1185825</guid><dc:creator><![CDATA[oslino]]></dc:creator><pubDate>Sat, 17 Jan 2015 14:23:44 GMT</pubDate></item><item><title><![CDATA[Reply to [PHP - OOP] Semplice classe OOP mi inchioda Firefox on Sat, 17 Jan 2015 13:19:05 GMT]]></title><description><![CDATA[<p dir="auto">Ciao,<br />
php è lato server ovviamente, quindi con la problematica di firefox in pratica c'entra pochissimo. L'unico modo per inchiodare il browser è mandargli in echo una marea di testo.</p>
]]></description><link>https://dev.connect.gt/post/1185832</link><guid isPermaLink="true">https://dev.connect.gt/post/1185832</guid><dc:creator><![CDATA[thedarkita]]></dc:creator><pubDate>Sat, 17 Jan 2015 13:19:05 GMT</pubDate></item></channel></rss>