Reply to Re: resultset and two tables in sql query

Your name:

Reply:


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
>
> }

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация