public function update($table, $data, $where = '')
    {
        $fieldDetails = null;
        foreach ($data as $key => $value) {
            $fieldDetails .= "$key = :$key,";
        }
        $fieldDetails = rtrim($fieldDetails, ',');
        $query = "UPDATE $table SET $fieldDetails ".($where ? 'WHERE '.$where : '');
        $this->prepare($query);

        foreach ($data as $key => $value) {
            $this->bind(":$key", $value);
        }
        try {
            $this->execute();

            return true;
        } catch (PDOException $e) {
            echo $e->errorInfo[2];

            return false;
        }
    }
public function update($table, $data, $where = '')
    {
        $fieldDetails = null;
        foreach ($data as $key => $value) {
            $fieldDetails .= "$key = :$key,";
        }
        $fieldDetails = rtrim($fieldDetails, ',');
        $query = "UPDATE $table SET $fieldDetails ".($where ? 'WHERE '.$where : '');
        $this->prepare($query);

        foreach ($data as $key => $value) {
            $this->bind(":$key", $value);
        }
        try {
            $this->execute();

            return true;
        } catch (PDOException $e) {
            echo $e->errorInfo[2];

            return false;
        }
    }
public function update ( $ table , $ data , $ where = '' ) { $ fieldDetails = null ; foreach ( $ data as $ key => $ value ) { $ fieldDetails .= "$key = :$key," ; } $ fieldDetails = rtrim ( $ fieldDetails , ',' ) ; $ query = "UPDATE $table SET $fieldDetails " . ( $ where ? 'WHERE ' . $ where : '' ) ; $ this -> prepare ( $ query ) ; foreach ( $ data as $ key => $ value ) { $ this -> bind ( ":$key" , $ value ) ; } try { $ this -> execute ( ) ; return true ; } catch ( PDOException $ e ) { echo $ e -> errorInfo [ 2 ] ; return false ; } }
Update data in the table
@param  string $table Table to be updated
@param  array $data  Key value pairs which you want to update
@param  string $where condition, in our case ID
Update data in the table