Re: [Phplib-users] DB putting results to strings
Brought to you by:
nhruby,
richardarcher
From: Stefan M. <me...@me...> - 2002-08-09 14:41:20
|
Hello Matthew, thanks for you fast responding. So I solved my problem by your suggestion in this way now: query="SELECT * FROM exampleDB"; $db1->query($query); $meta=$db1->metadata("", true); while ($db1->next_record()) { for ($i=0; $i<=$meta["num_fields"]; $i++) { $col=$meta[$i]["name"]; $$col=$db1->f($col); } echo $loginID; echo $other_colnamevalues; } Do you see an easier solution or a chance to put this whole thing into a function inside a new class that extends DB_Sql? Tried this in my own class DB_Example in local.inc: class DB_Example extends DB_Sql { var $classname = "DB_Example"; var $Host = "localhost"; var $Database = "example_base"; var $User = "user"; var $Password = "pass"; function get_values($table="") { global $query; $this->db = new $this->classname; $this->db->query($query); $meta=$this->db->metadata($table, true); for ($i=0; $i<=$meta["num_fields"]; $i++) { $col=$meta[$i]["name"]; $$col=$this->db->Record[$col]; } return $$col; } } Which should be used in this context: $query="SELECT * FROM exampleDB; $db->query($query); while ($db->next_record()) { $db->get_values(); echo $loginID; echo $other_colnamevalues; } But this didn't worked. Any new ideas? Thanks and Greetings, Stefan |