Previous Page
increment()

Solar_Example_Model_Nodes_Record
isChanged()

Next Page
key()

isChanged()

public void|bool isChanged ( string $col )

Tells if a particular table-column has changed.

Inherited from Solar_Sql_Model_Record.

Parameters

  • (string) $col: The table-column name.

Returns

  • (void|bool) Returns null if the table-column name does not exist, boolean true if the data is changed, boolean false if not changed.

Description

Tells if a particular table-column has changed.

This is slightly complicated. Changes to or from a null are reported as "changed". If both the initial value and new value are numeric (that is, whether they are string/float/int), they are compared using normal inequality (!=). Otherwise, the initial value and new value are compared using strict inequality (!==).

This complexity results from converting string and numeric values in and out of the database. Coming from the database, a string numeric '1' might be filtered to an integer 1 at some point, making it look like the value was changed when in practice it has not.

Similarly, we need to make allowances for nulls, because a non-numeric null is loosely equal to zero or an empty string.