ID:               24879
 Updated by:       [EMAIL PROTECTED]
 Reported By:      sm at grand-prix dot ru
-Status:           Open
+Status:           Duplicate
 Bug Type:         MySQL related
 Operating System: Linux RedHat 9
 PHP Version:      4.3.2
 New Comment:

see #21589


Previous Comments:
------------------------------------------------------------------------

[2003-08-04 03:13:21] sm at grand-prix dot ru

As i mean, bug occurs when both tables (main and left joined) contains
columns with equal names and left-joined table does'nt contain needed
row. In the such case named array elements with names, equal to such
column names are cleared.

Here is test script :
------------------------------------------------------------

<?php
  error_reporting(7);

  $srv = "mysql.server.ru";
  $usr = "username";
  $pwd = "password";
  $db = "database";

  $link_id=mysql_connect($srv,$usr,$pwd);  

  if (!$link_id) {
    echo "Can't connect to mysql server<br>";
    exit;
  }

  if (!mysql_select_db($db, $link_id)) {
    echo "Can't connect to mysql server<br>";
    exit;
  }

  if ($action == "create_bases") {

    $query = "CREATE TABLE test1table (
              userid int(10) unsigned DEFAULT '0' NOT NULL
auto_increment,
              usergroupid smallint(5) unsigned DEFAULT '0' NOT NULL,
              username varchar(50) NOT NULL,
              password varchar(50) NOT NULL,
              PRIMARY KEY(userid) )";

    $query_id = mysql_query($query,$link_id);
    if (!$query_id) {
      echo "invalid SQL:<br>$query<br>";
      exit;
    }


    $query = "CREATE TABLE test2table (
              userid int(10) unsigned DEFAULT '0' NOT NULL,
              field1 char(250) NOT NULL,
              field2 char(250) NOT NULL,
              field3 char(250) NOT NULL,
              field4 char(250) NOT NULL,
              PRIMARY KEY (userid) )";

    $query_id = mysql_query($query,$link_id);
    if (!$query_id) {
      echo "invalid SQL:<br>$query<br>";
      exit;
    }

    $query = "INSERT INTO test1table VALUES
(1,6,'user1','password1')";
    $query_id = mysql_query($query,$link_id);
    if (!$query_id) {
      echo "invalid SQL:<br>$query<br>";
      exit;
    }
    $query = "INSERT INTO test1table VALUES
(2,6,'user2','password2')";
    $query_id = mysql_query($query,$link_id);
    if (!$query_id) {
      echo "invalid SQL:<br>$query<br>";
      exit;
    }

    $query = "INSERT INTO test2table VALUES
(1,'dummy1','dummy2','dummy3','dummy4')";
    $query_id = mysql_query($query,$link_id);
    if (!$query_id) {
      echo "invalid SQL:<br>$query<br>";
      exit;
    }

    echo "<br>tables created and initialized<br>";
    exit;

  }

  $query = "SELECT * FROM test1table
            LEFT JOIN test2table ON
test2table.userid=test1table.userid
            WHERE test1table.userid=1";
  $query_id = mysql_query($query,$link_id);
  if (!$query_id) {
     echo "invalid SQL:<br>$query<br>";
     exit;
  }
  $array = mysql_fetch_array($query_id);
  print_r($array); 
  echo "<br><br>";
  mysql_free_result($query_id); 

  $query = "SELECT * FROM test1table
            LEFT JOIN test2table ON
test2table.userid=test1table.userid
            WHERE test1table.userid=2";
  $query_id = mysql_query($query,$link_id);
  if (!$query_id) {
     echo "invalid SQL:<br>$query<br>";
     exit;
  }
  $array = mysql_fetch_array($query_id);
  print_r($array); 
  echo "<br><br>";
  mysql_free_result($query_id); 


?>

------------------------------------------------------------------------

[2003-08-01 12:08:03] sm at grand-prix dot ru

I can provide more accurate test script and tables only on monday...
And I can't install RC version, I'm not a hoster...

But some important information - this problem persist only for such
database records, for which left joined records does'nt exist.

------------------------------------------------------------------------

[2003-08-01 08:45:46] [EMAIL PROTECTED]

And I asked you to try the SNAPSHOT, NOT the latest stable release..


------------------------------------------------------------------------

[2003-08-01 08:45:02] [EMAIL PROTECTED]

Please provide a complete but short example script and mysql db schema
with which we can reproduce this ourselves.
(we're not going to install vbulletin just to test this)


------------------------------------------------------------------------

[2003-08-01 04:02:21] sm at grand-prix dot ru

./configure :
 --with-mysql=/home/mysql
--with-apache=../apache_1.3.27rusPL30.17_match --enable-track-vars

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/24879

-- 
Edit this bug report at http://bugs.php.net/?id=24879&edit=1

Reply via email to