This topic is locked
[SOLVED]

 check before import

1/24/2012 7:59:30 AM
PHPRunner General questions
F
frphilip author

Hi,
I'm a newby user for phprunner. I'm looking to import datas into one table.
so, all is all right regarding import itself, no issue. But i need to check before insertinf one record, id this record does not already exists.
Well , I saw



//********** Check if specific record exists ************

global $conn;

$strSQLExists = "select * from AnyTable where SomeColumn='SomeValue'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data)

{

--rbegin--// if record exists do something--rend--

}

else

{

--rbegin--// if dont exist do something else--rend--

}
// Place event code here.

// Use "Add Action" button to add code snippets.
return true;


right. but 2 questions :

  • Where can I find the value of ''SomeValue'' to compare ? Is it the name of the comparing column in my csv file , or is it in one variable in the script ? So wich variable ? I can't find any information on how the datas are managed in the script...
  • Once checked, if the record exists in the table, I only want to skip (not insert) the line in my Csv file. How can I do that ? i believe that in the script, it should be a 'foreach' scanning all rows of my csv file, but i not sure...
    Thank you for your help
    // Place event code here.

    // Use "Add Action" button to add code snippets.
    return true;[/code]

F
frphilip author 1/24/2012

so nice, thanks.
I didn't even know that there was a documentation !