L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 14, 2008, 10:31:13 AM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Feedback and Suggestions > Topic: MySQL should have an option to return associative indexes and not just numeric
Pages: [1]   Go Down
« previous next »
Print
Author Topic: MySQL should have an option to return associative indexes and not just numeric  (Read 287 times)
0 Members and 1 Guest are viewing this topic.
Blueeagle
Omnipotent
BeBot Developer
Expert
********
Offline Offline

Gender: Male
Posts: 313



MySQL should have an option to return associative indexes and not just numeric
« on: February 05, 2007, 11:40:36 AM »

I am coding a module for bebot but I am annoyed by $this->bot->db->select only returning numeric indexes.

The fix I suggest is simple. The code as it stands now in MySQL.php (version 0.2.1) is:
Quote
function select ($sql)
{
   $data = "";
   $result = mysql_query($sql, $this->CONN);

   if (!$result)
   {
      $this -> error($sql);
      return false;
   }

   if (empty($result))
   {
      return false;
   }

   $count = 0;

   while ($row = mysql_fetch_array($result, MYSQL_NUM))
   {
      $data[$count] = $row;
      $count++;
   }

   mysql_free_result($result);
   return $data;
}

The change that I suggest would look something like:
Quote
function select ($sql, $result_form=MYSQL_NUM)
{
   $data = "";
   $result = mysql_query($sql, $this->CONN);

   if (!$result)
   {
      $this -> error($sql);
      return false;
   }

   if (empty($result))
   {
      return false;
   }

   while ($row = mysql_fetch_array($result, $result_form))
   {
      $data[] = $row;
   }

   mysql_free_result($result);
   return $data;
}

The default is set to MYSQL_NUM and the argument is optional as to not break modules already written.


Thank you for concidering this suggestion.

Edit: There was a way. Smiley

Terje Monsen
Blueeagl3 on RK1
« Last Edit: February 05, 2007, 11:48:03 AM by Blueeagle » Logged

The only problem that can't be solved by adding another wrapper is having too many wrappers.
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
Re: MySQL should have an option to return associative indexes and not just numer
« Reply #1 on: February 06, 2007, 12:24:49 PM »

Submitted to SVN trunk Smiley
Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Feedback and Suggestions > Topic: MySQL should have an option to return associative indexes and not just numeric
« previous next »
 
Jump to:  

Recent
Buddylist for guildbot
by Zacix
[Today at 09:43:40 AM]

Link 2 Guilds via 2 Bots?
by Temar
[Today at 08:42:11 AM]

OnlineOrg
by Karsta
[October 13, 2008, 06:54:20 AM]

!security Levels
by Nytridr
[October 12, 2008, 11:36:45 PM]

Bossloot for 5.2
by Brac
[October 12, 2008, 04:45:17 PM]

Ported Modules
by Jiheld
[October 12, 2008, 09:00:13 AM]

raid/point system suggest...
by Temar
[October 11, 2008, 11:45:40 PM]

!timers suggestions: alts...
by Alreadythere
[October 11, 2008, 03:19:46 PM]

!server does not work
by Alreadythere
[October 11, 2008, 06:54:38 AM]

TWC
by clashbot
[October 10, 2008, 08:52:57 AM]
Stats
Members
Total Members: 989
Latest: Syphae
Stats
Total Posts: 10814
Total Topics: 1459
Online Today: 14
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 1
Guests: 14
Total: 15
Zacix

Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.437 seconds with 28 queries. (Pretty URLs adds 0.03s, 4q)
Loading...