I've been having issues trying to run an insert statement via php to the iSeries DB2 via PDO odbc.
The following is my php script:
<?php
$empl_number = $argv[1];
$empl_estatus = $argv[2];
$empl_lname = $argv[3];
$empl_fname = $argv[4];
$empl_user = $argv[5];
try {
$sql = "INSERT INTO `USER_PROFILE_AD` (`EMPLOYEE_NUMBER`, `EMPLOYEE_STATUS`, `LAST_NAME`, `FIRST_NAME`, `LDAP_RDN`, `ACTIVE`, `USER_PROFILE`) VALUES (:numb, :stat, :lname, :fname, :usern, :active, :profile)";
$conn = new PDO("odbc:AS400TST");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare($sql);
$stmt->bindParam(':numb', $empl_number, PDO::PARAM_INT);
$stmt->bindParam(':stat', $empl_estatus, PDO::PARAM_STR);
$stmt->bindParam(':lname', $empl_lname, PDO::PARAM_STR);
$stmt->bindParam(':fname', $empl_fname, PDO::PARAM_STR);
$stmt->bindParam(':usern', $empl_user, PDO::PARAM_STR);
$stmt->bindParam(':active', 0, PDO::PARAM_INT);
$stmt->bindParam(':profile', NULL, PDO::PARAM_NULL);
$stmt->execute();
} catch (PDOException $e) {
echo $e->getMessage();
}
?>
When I run the script via command line...
user@server: /usr/bin/php myscript.php 1234 AC DOE JOHN JOHN.DOE
I get the following error message:
SQLSTATE[42000]: Syntax error or access violation: 0 [IBM][System i Access ODBC Driver]Statement violates access rule: Connection is set to read only. (SQLPrepare[0] at /builddir/build/BUILD/php-5.4.16/ext/pdo_odbc/odbc_driver.c:206)
I double-checked with the iSeries developer and the username that I using DOES have fully access to the database/table/etc...
Would you please help me to see why the insert doesn't work?
NOTES:
Connection works fine.
"Select" statements works just fine.
at /etc/odbc.ini, the CommitMode = 2
Thanks in advance,
EGMWEB