|
I wrote a function.
// ************************************************ *
// Function name: Ado_Db
// Function: execute SQL statement
// Parameter: $ sql--SQL statement
// $ mors--first select master-slave library 0 as slave library, 1 as master library, default slave library
// ************************************************ *
function Ado_Db ($ sql, $ mors = 0)
{
if ($ mors == 0)
{
GetSlave (); // Open the slave library, only for reading data (select)
mysql_select_db (DATANAME);
if (mysql_query ($ sql))
{
$ result = mysql_query ($ sql);
$ row = mysql_fetch_array ($ result);
return $ row;
}
else
{
return FALSE;
}
}
else
{
GetMaster (); // Open the main library and write the library (DELETE, UPDATE, INSERT)
mysql_select_db (DATANAME);
if (! mysql_query ($ sql))
{
return FALSE;
}
}
Ranch
}
-------------------------------------------------- --------
$ row = Ado_Db ($ sql);
I want the function to first determine if the database has this record. If there is one, it returns an array to $ ROW. If there is no record, it returns a FALSE to $ row. Please help me to see how I can modify this custom function. |
|