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?
September 07, 2008, 11:31:08 PM

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 279 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
Help with online info in ...
by Barlyman
[Today at 07:56:24 PM]

BeBot v0.5.3 released (de...
by Temar
[Today at 07:51:18 PM]

Security
by Alreadythere
[September 06, 2008, 10:02:42 AM]

Probs with relay from gue...
by Temar
[September 06, 2008, 09:03:06 AM]

Raid spam in guild chat
by Temar
[September 06, 2008, 09:01:18 AM]

Org Relaying
by Nytridr
[September 06, 2008, 01:34:35 AM]

Link 2 Guilds via 2 Bots?
by Temar
[September 05, 2008, 04:22:40 PM]

SVN download
by clashbot
[September 05, 2008, 05:12:59 AM]

TWC
by Temar
[September 05, 2008, 12:27:23 AM]

How to find the guild ID?...
by Irinir
[September 03, 2008, 02:58:54 PM]
Stats
Members
Total Members: 965
Latest: morisey
Stats
Total Posts: 10414
Total Topics: 1413
Online Today: 18
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 2
Guests: 21
Total: 23
egrath
blackspell

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.364 seconds with 28 queries. (Pretty URLs adds 0.031s, 4q)
Loading...