From 4c70aa2d46f33c6ca36b03729f20ec767b324717 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Wed, 10 Oct 2018 16:17:48 +0530 Subject: [PATCH] Fix saving and getting boolean value Signed-off-by: Riddhesh Sanghvi --- php/EE/Model/Base.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/php/EE/Model/Base.php b/php/EE/Model/Base.php index 2d8ee3baf..cb187beed 100644 --- a/php/EE/Model/Base.php +++ b/php/EE/Model/Base.php @@ -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 ) @@ -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, [