|
Posted by michael on 12/07/07 10:44
Hi,
Yes you can get the tablename from any table even without writing the
SQL.
$sql = "select * from tablea a1,tableb b1 where b1.id = a1.id";
$result = mysql_query($sql);
//read meta data
for ($i=0;$i<mysql_num_fields($result);$i++){
$field = mysql_fetch_field($result,$i);
$meta[$field->name] = $field->table;
}
// now loop throw the resultset like you normally do.
now you can check the column name in your meta data to get the table
name.
var_dump($meta);
I hope this helps you
//Michael
On 3 Dec., 21:23, bender <norep...@cause.spam> wrote:
> Is possible to read variable using table.fieldName like in example?
>
> example query: SELECT table1.*, table2.* FROM teble1, table2 WHERE
> table1.id = table2.id;
>
> $rs = $this->dbc->query($sql->createSelect());
> while($row=$rs->fetch_array()){
> $retVal[]=$row[table.fieldName] // doesnt work, $row[fieldName] //does
> work
>
> }
Navigation:
[Reply to this message]
|