Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion php/EE/Model/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,18 @@ public static function create( $columns = [] ) {
* Returns all model with condition
*
* @param string|array $column Column to search in
* @param string $value Value to match
* @param string $value Value to match
*
* @throws \Exception
*
* @return array
*/
public static function where( $column, $value = '' ) {

if ( is_bool( $value ) ) {
$value = (int) $value;
}

return static::many_array_to_model(
EE::db()
->table( static::$table )
Expand Down Expand Up @@ -245,8 +250,15 @@ public function __unset( $name ) {
* @return bool Model saved successfully
*/
public function save() {

$fields = $this->fields;

foreach ( $fields as $key => $value ) {
if ( is_bool( $value ) ) {
$fields[ $key ] = (int) $value;
}
}

if ( static::$needs_update_timestamp ) {
$fields = array_merge(
$fields, [
Expand Down