I have two tables:
Teacher: ID, last_name, first_name
Student: ID,last_name,first_name, Instructor_id
two tables are linked by teacher.id=student.instructor_id
In Php 4.2.0,
{
$db_connstr="~~~";
$db_con = new COM("ADODB.Connection");
$db_con->open($db_connstr);
$query="select * from teacher,student where teacher.id=student.instructor_id";
$rs=$db_con->execute($query);
While (!$rs->eof)
{
$icount=$rs->fields->count();
for ($i=0;$i<$icount;$i++)
{
print $rs->fields[$i]->name;
print $rs->fields[$i]->value;
}
}
The script works fine and return all the fields. But the problem is both tables have the last_name and first_name fields. And the returned recordset doesn't add the table name "teacher." or "student." in front of the fields. So I can't distinguish those fields by specifying "$rs->fields['student.last_name']->value". If I do so, php give a warning saying:
Warning: Invoke() failed: Exception occurred. Source: ADODB.Fields Description: Item cannot be found in the collection corresponding to the requested name or ordinal.
I have to bypass this error by "select teacher.last_name as tlname......"
Is this a bug or I made a stupid mistake.
Any suggestion will be welcomed?