note 30283 modified in function.ocifetchstatement by sixd
| From: | sixd@php.net | Date: | Thu, 08 Oct 2009 19:19:31 +0000 |
| Subject: | note 30283 modified in function.ocifetchstatement by sixd | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161535@lists.php.net to get a copy of this message | ||
One thing I found with this:
If you have two tables with the same column names, you will run into problems when displaying them,
i.e:
$sql = "select a.name, b.name, c.phone
from table1 a, table2 b, table3 c";
php will overwrite the a.name display cell with the b.name value. So you wanted three cells to
display and you are only getting two. i.e.
What you wanted:
----------------------------------------
| Bob | Jones | 555-555-5555 |
----------------------------------------
What you got:
-----------------------------------------
| Jones | 555-555-5555 | |
-----------------------------------------
Resolution: rename your table column names as they come in.
$sql = "select a.name, b.name AS NAME2, c.phone
from table1 a, table2 b, table3 c";
--was--
One thing I found with this:
If you have two tables with the same column names, you will run into problems when displaying them,
i.e:
$sql = "select a.name, b.name, c.phone
from table1 a, table2 b, table3 c";
php will overwrite the a.name display cell with the b.name value. So you wanted three cells to
display and you are only getting two. i.e.
What you wanted:
----------------------------------------
| Bob | Jones | 555-555-5555 |
----------------------------------------
What you got:
-----------------------------------------
| Jones | 555-555-5555 | |
-----------------------------------------
Resolution: rename your table column names as they come in.
$sql = "select a.name, b.name AS NAME2, c.phone
from table1 a, table2 b, table3 c";
http://php.net/manual/en/function.ocifetchstatement.php