<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/20279" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2017-01-31T03:50:43-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/20279</id>

		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2017-01-31T03:50:43-04:00</updated>

		<published>2017-01-31T03:50:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105776#p105776</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105776#p105776"/>
		<title type="html"><![CDATA[How to list &amp; close active mysqltcl sessions]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105776#p105776"><![CDATA[
With string match i tryed yet when the result comes to mIRC it has '?' instead of the letter maybe thats why is not being modifyed.<br><br>I will try with WHERE in the next version, my problem now is that some use "ă" "a" "ş" "s" in TITLE and the link is not accesible<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Tue Jan 31, 2017 3:50 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2017-01-31T01:49:21-04:00</updated>

		<published>2017-01-31T01:49:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105775#p105775</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105775#p105775"/>
		<title type="html"><![CDATA[How to list &amp; close active mysqltcl sessions]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105775#p105775"><![CDATA[
If you want to get only the <em class="text-italics">s_slug</em> of a record that has <em class="text-italics">fk_i_category_id</em> equal with the given <em class="text-italics">number</em> and limit yourself to a single result then why not change the select and drop the unnecessarily loops? Something like:<div class="codebox"><p>Code: </p><pre><code>set data [::mysql::sel $handle "SELECT s_slug FROM an_t_category_description WHERE fk_i_category_id = $number LIMIT 0, 1" -list]</code></pre></div>and then <em class="text-italics">$data</em> should be a list containing the <em class="text-italics">s_slug</em> you are looking for. Give this a try and let me know the result.<br><br>If you want to see all matches then remove the limit and use a single loop like i mentioned in first post to go over all results.<br><br>Sure:<div class="codebox"><p>Code: </p><pre><code>set text [string map -nocase [list "ă" "a" "ş" "s" ... ] $text]</code></pre></div>you get the idea. Not 100% sure if the <em class="text-italics">-nocase</em> will also work with the upper-case so you should check this out and if doesn't work add them as well.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Tue Jan 31, 2017 1:49 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2017-01-30T15:59:19-04:00</updated>

		<published>2017-01-30T15:59:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105774#p105774</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105774#p105774"/>
		<title type="html"><![CDATA[How to list &amp; close active mysqltcl sessions]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105774#p105774"><![CDATA[
That i need.<br><br>Another question do you have any code to modify "ă" into 'a'<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Mon Jan 30, 2017 3:59 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2017-01-30T15:49:04-04:00</updated>

		<published>2017-01-30T15:49:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105773#p105773</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105773#p105773"/>
		<title type="html"><![CDATA[How to list &amp; close active mysqltcl sessions]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105773#p105773"><![CDATA[
That's great, but what about the select?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Jan 30, 2017 3:49 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2017-01-30T14:39:33-04:00</updated>

		<published>2017-01-30T14:39:33-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105770#p105770</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105770#p105770"/>
		<title type="html"><![CDATA[How to list &amp; close active mysqltcl sessions]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105770#p105770"><![CDATA[
Thanks sticking out the return in the foreach loop. That was the problem solved it. Thanks again.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Mon Jan 30, 2017 2:39 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2017-01-30T12:51:50-04:00</updated>

		<published>2017-01-30T12:51:50-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105769#p105769</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105769#p105769"/>
		<title type="html"><![CDATA[How to list &amp; close active mysqltcl sessions]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105769#p105769"><![CDATA[
Let's put the above code in theory and see what really happens inside.<div class="codebox"><p>Code: </p><pre><code>% set data [list "1" "3" "5" "2" "9" "7"]1 3 5 2 9 7% proc foo {a} {        foreach i $a {                if {$i eq 2} {                        return $i                }        }        puts "done?"}</code></pre></div>Considering the above code, what happens when I execute "foo $data" ? Will i get to see the "done" message? Answer is NO!<div class="codebox"><p>Code: </p><pre><code>% foo $data2</code></pre></div>Why don't we see it? Umm.. Because of the return statement maybe? <br><br>Let's see. If we change the above code a bit to add something so we know we had a match and break the loop when we got this match (if this was what we where looking for in the first place).<div class="codebox"><p>Code: </p><pre><code>proc foo {a} {set match 0foreach i $a {if {$i eq 2} {incr matchbreak}}puts "done?"return $match}</code></pre></div>then the result is:<div class="codebox"><p>Code: </p><pre><code>% foo $datadone?1</code></pre></div>OMG! It works!<br><br>Bottom line is: never, ever use a <em class="text-italics">return</em> inside a loop. Break it if your proc matched something or use continue if it didn't.<br><br>Long story told short, you get this issue because of the return that stops the process before reaching the part where it closes the session to the mysql database.<br><br>PS: You should drop the <em class="text-italics">-list</em> at the end if you just want to see the number of rows returned as the result of the query.<blockquote class="uncited"><div>If sql-statement is a SELECT statement and no -list or -flatlist option is specified, the command returns the number of rows returned as the result of the query. The rows can be obtained by the ::mysql::fetch and/or the ::mysql::map commands.</div></blockquote>Taken from <a href="http://www.xdobry.de/mysqltcl/mysqltcl.html#3" class="postlink">::mysql:sel's documentation</a><br><br>As it stands right now your select statement looks rather dumb. What exactly do you want to achive there? Want to see if there's something in the database with a <em class="text-italics">fk_i_category_id</em> that is matching the given <em class="text-italics">number</em>? Do you <em class="text-italics">sanitize</em> that number btw?<br><br>I would consider doing at least a:<div class="codebox"><p>Code: </p><pre><code>if {![string is integer $number]} return</code></pre></div>or something.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Jan 30, 2017 12:51 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2017-01-30T12:35:17-04:00</updated>

		<published>2017-01-30T12:35:17-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105768#p105768</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105768#p105768"/>
		<title type="html"><![CDATA[How to list &amp; close active mysqltcl sessions]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105768#p105768"><![CDATA[
I rewrote the script ... and used closed at the end .. here is an example ..<br><br><div class="codebox"><p>Code: </p><pre><code>proc sql:category {number} {global myset handle [::mysql::connect -host $my(host) -user $my(user) -password $my(pass) -db $my(db) -port $my(port)]set go [::mysql::sel $handle "SELECT `fk_i_category_id`,`s_name`,`s_description`,`s_slug` FROM `an_t_category_description` ORDER BY `fk_i_category_id`" -list]foreach item $go {foreach {fk_i_category_id s_name s_description s_slug} $item {if {$number eq $fk_i_category_id} {return "$s_slug"}}}::mysql::close $handle}</code></pre></div>The problem is that i checked the mysql phpmyadmin and i see that the connection stays open... and multiplies each time i read data. So the connection is not closing from the eggdrop <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_neutral.gif" width="15" height="15" alt=":|" title="Neutral"><br><br>There is no way to read what mysql connections i have opened in eggdrop?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Mon Jan 30, 2017 12:35 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2017-01-30T12:35:35-04:00</updated>

		<published>2017-01-30T12:23:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105767#p105767</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105767#p105767"/>
		<title type="html"><![CDATA[How to list &amp; close active mysqltcl sessions]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105767#p105767"><![CDATA[
Why don't you close the session when you no longer need it?<br>Something like:<div class="codebox"><p>Code: </p><pre><code>set dbh [::mysql::connect -host $my(host) -user $my(user) -password $my(pass) -db $my(db) -port $my(port)]foreach res [::mysql::sel $dbh {"SELECT pk_i_id, fk_i_category_id, dt_pub_date FROM an_t_item ORDER BY dt_pub_date DESC LIMIT 0, 1"} -list] {# do whatever with the data}::mysql::close $dbh</code></pre></div>Untested.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Jan 30, 2017 12:23 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Madalin]]></name></author>
		<updated>2017-01-30T02:58:00-04:00</updated>

		<published>2017-01-30T02:58:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105766#p105766</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105766#p105766"/>
		<title type="html"><![CDATA[How to list &amp; close active mysqltcl sessions]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105766#p105766"><![CDATA[
I am reading a mysql database in the following way<br><div class="codebox"><p>Code: </p><pre><code>set num [catch {::mysql::connect -host $my(host) -user $my(user) -password $my(pass) -db $my(db) -port $my(port)} mysocket]if {$num eq "0" &amp;&amp; [string match mysql* $mysocket]} {set num [catch {mysqlsel $mysocket "SELECT `pk_i_id`,`fk_i_category_id`,`dt_pub_date` FROM `an_t_item` ORDER BY `dt_pub_date` DESC LIMIT 0, 1" -list} select];if {$num eq "0" &amp;&amp; $select ne ""} {foreach item $select {</code></pre></div>..and from time to time the database is not accesible until i restart it and i wanted to know how manny active session i have with that specific database.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6396">Madalin</a> — Mon Jan 30, 2017 2:58 am</p><hr />
]]></content>
	</entry>
	</feed>
