note 57430 deleted from function.mysql-num-rows by jome
| From: | jome@php.net | Date: | Tue, 04 Oct 2005 04:38:52 +0000 |
| Subject: | note 57430 deleted from function.mysql-num-rows by jome | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96331@lists.php.net to get a copy of this message | ||
Note Submitter: jared at bsdcertification.com
----
In order to check if a row exists, what is the best function? I am currently using this:
function row_exist($value,$table,$wherecol = 0,$whereval = 0,$dbc,$dbname)
{
mysql_select_db($dbname,$dbc) or die(__FILE__ . " - line: " . __LINE__ . " -
mysql error");
$query = "SELECT $value from $table";
if ($wherecol and $whereval)
{
$query = "$query" . " where $wherecol='$whereval'";
}
$numrows = mysql_num_rows(mysql_query("$query", $dbc));
if ($numrows) return 1;
return 0;
}
This will do what i want, I am just wondering if anyone has simpler, more efficient method they use
for checking for the existence of a row in a table.