public function updatePDO($table, array $data, array $where = array())
    {

        if (count($data) === 0) {
            return false;
        }
        $q = "UPDATE `$table` SET ";

        foreach ($data as $key => $val) {
            if (null !== $val) {
                $q .= "`$key`=?, ";
            }
        }
        $q = rtrim($q, ', ') . ' WHERE ';

        foreach ($where as $key => $val) {
            if (null !== $val) {
                $q .= "`$key`=? AND ";
            }
        }
        $q = rtrim($q, 'AND ') . ' ;';

        try {
            $this->_queryId = self::$_linkId->prepare($q);

            $i = 1;
            foreach ($data as $key => $val) {
                if (null !== $val) {
                    $type = $this->getPDOConstantType($val);
                    $this->_queryId->bindValue($i, $val, $type);
                    ++$i;
                }
            }


            foreach ($where as $key => $val) {
                $type = $this->getPDOConstantType($val);
                $this->_queryId->bindValue($i, $val, $type);
                ++$i;
            }
            return $this->_queryId->execute();
        } catch (PDOException $e) {
            $this->_error = $e->getMessage();
            return false;
        }
    }
public function updatePDO($table, array $data, array $where = array())
    {

        if (count($data) === 0) {
            return false;
        }
        $q = "UPDATE `$table` SET ";

        foreach ($data as $key => $val) {
            if (null !== $val) {
                $q .= "`$key`=?, ";
            }
        }
        $q = rtrim($q, ', ') . ' WHERE ';

        foreach ($where as $key => $val) {
            if (null !== $val) {
                $q .= "`$key`=? AND ";
            }
        }
        $q = rtrim($q, 'AND ') . ' ;';

        try {
            $this->_queryId = self::$_linkId->prepare($q);

            $i = 1;
            foreach ($data as $key => $val) {
                if (null !== $val) {
                    $type = $this->getPDOConstantType($val);
                    $this->_queryId->bindValue($i, $val, $type);
                    ++$i;
                }
            }


            foreach ($where as $key => $val) {
                $type = $this->getPDOConstantType($val);
                $this->_queryId->bindValue($i, $val, $type);
                ++$i;
            }
            return $this->_queryId->execute();
        } catch (PDOException $e) {
            $this->_error = $e->getMessage();
            return false;
        }
    }
public function updatePDO ( $ table , array $ data , array $ where = array ( ) ) { if ( count ( $ data ) === 0 ) { return false ; } $ q = "UPDATE `$table` SET " ; foreach ( $ data as $ key => $ val ) { if ( null !== $ val ) { $ q .= "`$key`=?, " ; } } $ q = rtrim ( $ q , ', ' ) . ' WHERE ' ; foreach ( $ where as $ key => $ val ) { if ( null !== $ val ) { $ q .= "`$key`=? AND " ; } } $ q = rtrim ( $ q , 'AND ' ) . ' ;' ; try { $ this -> _queryId = self :: $ _linkId -> prepare ( $ q ) ; $ i = 1 ; foreach ( $ data as $ key => $ val ) { if ( null !== $ val ) { $ type = $ this -> getPDOConstantType ( $ val ) ; $ this -> _queryId -> bindValue ( $ i , $ val , $ type ) ; ++ $ i ; } } foreach ( $ where as $ key => $ val ) { $ type = $ this -> getPDOConstantType ( $ val ) ; $ this -> _queryId -> bindValue ( $ i , $ val , $ type ) ; ++ $ i ; } return $ this -> _queryId -> execute ( ) ; } catch ( PDOException $ e ) { $ this -> _error = $ e -> getMessage ( ) ; return false ; } }
Does an update query with an array for data and array as a param for the where clause
@access public
@param String $table
@param Array $data is an assoc array with keys are column names and values as the actual values
@param Array $where
@return Boolean Returns TRUE on success or FALSE on failure.
Does an update query with an array for data and array as a param for the where clause