i'm working on a new project that has many db functions. Before i ask the question, i'll show an example of some code:
PHP Code:
<?
deleteAgent($agent_id)
{
$result=mysql_query("delete from agents where agent_id='$agent_id'");
$num=mysql_numrows($result);
if($num == 0)
{
return 0;
}
else
{
return 1;
}
}
?>
is this the best way to return 1 if the query actually executed something? for example, i want to use the function like this:
PHP Code:
<?
if(deleteAgent($agent_id))
{
echo "Agent delted successfully.";
}
else
{
echo "There was an error deleting this agent.";
}
?>
it seems like a simple thing to do, .. i'm just making sure this is the best way to do it.