Jump to content

SQL Query function help


Mutley

Recommended Posts

I'm wanting to execute functions rather than having to type out a query each time, at the moment I do this sort of thing:

 

<?php
$res=mysql_query("SELECT field FROM `table` WHERE where");
while($row=mysql_fetch_array($res)){
$variable = $row[""];
}

$sql="SELECT * FROM table WHERE where LIMIT 1";
$res=mysql_query($sql);
if(mysql_num_rows($res)!=0) {
while(list($variables) = mysql_fetch_row($res)){
$variables;
}
}
?>

 

Now I saw this:

http://www.devshed.com/c/a/PHP/Creating-a-Secure-PHP-Login-Script/

 

Where they do queries by doing $db->

<?php
$sql = "UPDATE member SET session = $session, ip = $ip WHERE " .
"id = $this->id";
$this->db->query($sql);?>

 

However I can't get my head around it, what is it doing? I've not really used -> before so don't understand what that refers to either.

 

And would a function to execute queries only be limited to certain queries?

 

Thanks in advance.

 

 

Link to comment
https://forums.phpfreaks.com/topic/167482-sql-query-function-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.