Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By BinaCh
#812757
I'm trying to insert data into an external database from a dynaform but I can not. Please, you can give me the trigger code that does that.
User avatar
By amosbatto
#812761
Let's say that you have table in your external database named CLIENTS with the fields FIRST_NAME, LAST_NAME, CONTRACT_START_DATE, SALARY, and AGE and you have the following variables associated with fields in your Dynaform: firstName, lastName, contractStartDate, salary and age.

First, create a Database Connection to your external database and copy it UID, because you will need it when calling executeQuery(). Then create a trigger similar to the following one:
Code: Select all
$db = '1234567890abcde1234567890abcde'; //set to the UID of the database connection;

//check if one variable is set, to make sure that the dynaform was submitted:
if (isset(@@firstName)) {   
   //use mysql_real_escape_string(), mysqli_real_escape_string() or addslashes() as a last resort 
   //to escape strings to prevent SQL injection attacks:
   $firstName = mysql_real_escape_string(@@firstName); 
   $lastName = mysql_real_escape_string(@@lastName);

   //Datetimes are in "YYYY-MM-DD HH:MM:SS" format which works to insert in MySQL, PostgreSQL 
   //and MS SQL Server, but needs to be formatted with the TO_DATE() function in Oracle.
   //access datetime variables as strings. 
   //Set as NULL if empty or a string enclosed in single quotation marks.
   $startDate = empty(@@contractStartDate) ? NULL : "'". @@contractStartDate . "'";
   
   $salary = @#salary; //access as a floating-point number
   $age = @%age;  //access as an integer

   //make sure to include strings and dates inside single quotation marks, but numbers don't need them.
   $sql = "INSERT INTO CLIENTS (FIRST_NAME, LAST_NAME, CONTRACT_START_DATE, SALARY, AGE) 
        VALUES ('$firstName', '$lastName', $startDate, $salary, $age)"; 
   
   executeQuery($sql, $db); 
} 
By NAlvarado
#815484
I am having trouble with inserting this date into Oracle.

@@creationDate = getCurrentDate();
$creationDate = @@creationDate;

I have tried the following for the insert portion in a trigger but it continues to fail. Advice/suggestions? Thanks

TO_DATE($creationDate,'MM/DD/YYYY')
TO_DATE('$creationDate','MM/DD/YYYY')

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]