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?
December 01, 2008, 01:21:48 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 300 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
[request] Raid timers
by Alreadythere
[Today at 11:42:32 AM]

Shared DB online list
by Temar
[Today at 01:55:47 AM]

relay colors
by Temar
[Today at 01:54:56 AM]

BeBot v0.6.0 released
by Alreadythere
[November 30, 2008, 05:32:00 PM]

Change to Bid.php
by Temar
[November 30, 2008, 11:41:44 AM]

OnlineOrg
by Jiheld
[November 29, 2008, 12:44:27 PM]

Silly Newbie Question.
by Temar
[November 29, 2008, 12:00:02 PM]

massive_pvp_time_table 1
by gerborg
[November 29, 2008, 06:55:35 AM]

Bot not see Guild Chat
by Delvar
[November 28, 2008, 08:30:34 AM]

Starting Bot
by Allisande
[November 28, 2008, 07:08:21 AM]
Stats
Members
Total Members: 1243
Latest: Whackoeng
Stats
Total Posts: 11143
Total Topics: 1505
Online Today: 21
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 1
Guests: 11
Total: 12
egrath

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