This topic is locked

Import Event

6/15/2009 10:54:10 AM
PHPRunner General questions
C
christwigg74 author

Hi all
I would like to insert the current date and userID into usernameID and Import_Date fields during/after an csv import.
Any Ideas ?
Many Thanks

J
Jane 6/16/2009

Hi,
you need to edit generated ..._import.php file manually. Find and edit insert query in this file.

Username of current user is in the $_SESSION["UserID"] variable.

C
christwigg74 author 6/16/2009

Thanks for the reply
I've looked for this insert query in the generated import.php but find it all extremely confusing.
My table name is Import & UsernameID is the field.
Can anyone point me in the right direction please ?
Many thanks

J
Jane 6/16/2009

Hi,
here is just a sample:

$sql = "insert into ".AddTableWrappers($strOriginalTableName)." (".implode(",", $fields).",UsernameID) values (".implode(",", $arr) .",'".$_SESSION["UserID"]."')";

C
christwigg74 author 6/16/2009

Thank you so much!!
php is a nightmare for me

C
christwigg74 author 6/16/2009

For anyone else having similar problems ?
(this code i believe is only applicable to advanced security i.e create login page using a user table)
I was trying to use this code to add the logged in userID to a table during a csv import in the file (yourpage.import.php)
$sql = "insert into ".AddTableWrappers($strOriginalTableName)." (".implode(",", $fields).",yourfield) values (".implode(",", $arr) .",'".$_SESSION["UserID"]."')";
This created errors as its trying to use the users logged in name and not the userID primary key
I changed the SESSION to :-
$sql = "insert into ".AddTableWrappers($strOriginalTableName)." (".implode(",", $fields).",yourfield) values (".implode(",", $arr) .",'".$_SESSION["OwnerID"]."')";
And now it passes the userID primary key number from the users table.
Once again thanks to Jane for her help!!
Now to try and add another field as date imported :S
Good luck all