fix small issues on checking success of a db query

main
msquare 8 years ago
parent 0d772ec908
commit e93dd774a5

@ -64,7 +64,7 @@ function EventConfig_update(
); );
} }
return (bool)DB::update(' return DB::update('
UPDATE `EventConfig` SET UPDATE `EventConfig` SET
`event_name` = ?, `event_name` = ?,
`buildup_start_date` = ?, `buildup_start_date` = ?,

@ -81,31 +81,31 @@ class Db
} }
/** /**
* Run a insert query * Run an insert query
* *
* @param string $query * @param string $query
* @param array $bindings * @param array $bindings
* @return bool * @return int|bool
*/ */
public static function insert($query, array $bindings = []) public static function insert($query, array $bindings = [])
{ {
self::query($query, $bindings); self::query($query, $bindings);
return self::$lastStatus; return (self::$lastStatus ? self::$stm->rowCount() : false);
} }
/** /**
* Run a update query * Run an update query
* *
* @param string $query * @param string $query
* @param array $bindings * @param array $bindings
* @return int|null * @return int|bool
*/ */
public static function update($query, array $bindings = []) public static function update($query, array $bindings = [])
{ {
self::query($query, $bindings); self::query($query, $bindings);
return (self::$lastStatus ? self::$stm->rowCount() : null); return (self::$lastStatus ? self::$stm->rowCount() : false);
} }
/** /**
@ -113,13 +113,13 @@ class Db
* *
* @param string $query * @param string $query
* @param array $bindings * @param array $bindings
* @return int|null * @return int|bool
*/ */
public static function delete($query, array $bindings = []) public static function delete($query, array $bindings = [])
{ {
self::query($query, $bindings); self::query($query, $bindings);
return (self::$lastStatus ? self::$stm->rowCount() : null); return (self::$lastStatus ? self::$stm->rowCount() : false);
} }
/** /**

Loading…
Cancel
Save