Questions about the returned objects in the query // The Object class PHPcodeclassNewes {// varadvertisingid; // varadcontent; privateintadvertisingid; privateSt
// Entity class
PHP code
class Newes { //var advertisingid; //var adcontent; private int advertisingid; private String adcontent; private String texttitle; private String prclink; private String time; private String urllink; private int newtype; private String newlaiyuan; public function getId() { return $this->advertisingid; } public function setId($advertisingid) { $this->advertisingid=$advertisingid; return $this; } public function getAdcontent() { return $this->adcontent; } public function setAdcontent($adcontent) { $this->adcontent=$adcontent; return $this; } public function getTexttitle() { return $this->texttitle; } public function setTexttitle($texttitle) { $this->texttitle=$texttitle; return $this; } }
Solution
PHP code
$sql="select * from newes where advertisingid =1";$abc =mysql_query($sql);/**while($num =mysql_fetch_array($abc)){ $num}*/
Q: How can I return an object class?
For example, Newes $ newes = new Newes ();
$ Newes = mysql_query ($ SQL); // Is this an object class returned?
Super beginner confused... please help me explain. thank you.
------ Solution --------------------
What is the relationship between the two codes ??
First returns the object class
The second mysql_query returns the result set of the resource type.
------ Solution --------------------
Such as: private int advertisingid; changed to private $ advertisingid;
Your set is the definition method in java.
------ Solution --------------------
Mysql_fetch_row ()
Mysql_fetch_array ()
Mysql_fetch_assoc ()
For details about the differences, refer to Google.