/** * If table key (id) is NULL : inserts a new row * otherwise updates existing row in the database table * * Can be overridden or overloaded by the child class * * @param boolean $updateNulls TRUE: null object variables are also updated, FALSE: not. * @return boolean TRUE if successful otherwise FALSE */ public function store( $updateNulls=false ) { global $_CB_framework; if ( $this->time_paid && ( $this->time_paid != $this->_db->getNullDate() ) ) { $offset = (int) $_CB_framework->getCfg( 'offset' ) * 3600; list($y, $c, $d, $h, $m, $s) = sscanf( $this->time_paid, '%d-%d-%d %d:%d:%d'); $time_paid = mktime($h, $m, $s, $c, $d, $y); // we do NOT use PHP strtotime, which is broken $time_paid += $offset; $dateDayHour = explode( ' ', date( 'Y-m-d w H o W', $time_paid ) ); $dateDayHour[1] += 1; // --> 1 = Sunday...7 = Saturday, ISO-8601 numeric representation of the day of the week, like MySQL $this->time_paid_date = $dateDayHour[0]; $this->time_paid_day_of_week = $dateDayHour[1]; $this->time_paid_yearweek = $dateDayHour[3] . '-W' . $dateDayHour[4]; $this->time_paid_yearmonth = substr( $dateDayHour[0], 0, 7 ); $this->time_paid_hour = $dateDayHour[2]; } return parent::store( $updateNulls ); }
/** * If table key (id) is NULL : inserts a new row * otherwise updates existing row in the database table * * Can be overridden or overloaded by the child class * * @param boolean $updateNulls TRUE: null object variables are also updated, FALSE: not. * @return boolean TRUE if successful otherwise FALSE */ public function store($updateNulls = false) { if ($this->time_completed && $this->time_completed != $this->_db->getNullDate()) { $time_paid = cbpaidTimes::getInstance()->strToTime($this->time_completed); // we do NOT use PHP strtotime, which is broken $dateDayHour = explode(' ', cbpaidTimes::getInstance()->localDate('Y-m-d w H o W', $time_paid)); $dateDayHour[1] += 1; // --> 1 = Sunday...7 = Saturday, ISO-8601 numeric representation of the day of the week, like MySQL $this->time_completed_date = $dateDayHour[0]; $this->time_completed_day_of_week = $dateDayHour[1]; $this->time_completed_yearweek = $dateDayHour[3] . '-W' . $dateDayHour[4]; $this->time_completed_yearmonth = substr($dateDayHour[0], 0, 7); $this->time_completed_hour = $dateDayHour[2]; } return parent::store($updateNulls); }