0

Good day everybody,

Unfortunately my UPDATE does not save in the DB.

There is no error message or the like.

The output values ​​are also correct, as is the SQL command. I copied the command from mysql.log and pasted it into the Navicat. Without problems.

From zzz to yyy

PHP:

if ($basedataValue != $formDaten) {
                    $sql = "UPDATE tab_basedata SET basedata_value = :value WHERE basedata_key = :basedatakey";
                    $options = array(
                        ":basedatakey" => $tableKeyName,
                        ":value" => $formDaten
                    );
                    $db->pdoExecute($sql, $options);

public function pdoExecute(string $query, array $options = null)
{
    $rs = $this->prepare($query);
    debugS($query);
    if ($options !== null) {
        foreach ($options as $key => &$option) {
            if (isNumeric($option)) {
                debugS($key."(numeric)");
                debugS($option."(numeric)");
                $rs->bindParam($key, $option, PDO::PARAM_INT);
            } else {
                debugS($key."(str)");
                debugS($option."(str)");
                $rs->bindParam($key, $option, PDO::PARAM_STR);
            }
        }
    }
    if (!$rs->execute()) $this->_on_error("DB-Error", "SQL Error in: " . $query . " - " . $rs->errorInfo()[2], $rs->debugDumpParams());
}

Output from my debugS()

UPDATE tab_basedata SET basedata_value = :value WHERE basedata_key = :basedatakey
:basedatakey(str)
global_adresse(str)
:value(str)
yyy(str)

I am thankful for every help

  • So what does `_on_error` do? – DarkBee Aug 31 '20 at 07:22
  • Check the value of `$rs->rowCount()`. If it says 0, then you probably have a typo in `global_adresse` or something. In any case, if the `execute()` call didn't return `false` then the query went through. – Jeto Aug 31 '20 at 07:26
  • @jeto $rs->rowCount() is 1 and execute() is true but nothing happend. – Nico Stark Aug 31 '20 at 08:26
  • @DarkBee `_on_error` logs the error in the DB if `execute()` fails and formats the output – Nico Stark Aug 31 '20 at 08:32
  • Then your query succeeded @DarkBee. Are you sure your PDO is set up with the right database? – Jeto Aug 31 '20 at 08:42
  • yep, i'am sure. 248 Connect xxx@xxx as anonymous on tab_test UPDATE tab_basedata SET basedata_value = 'yyy' WHERE basedata_key = 'global_adresse' i use the function often and there are no problems there – Nico Stark Aug 31 '20 at 09:03

0 Answers0