/** * Gets a position ID from a position array. * If it's needed, it will save a new row in the posizione table. * * @param array $positionObj * * @return AMA_Error on error | number position id * * @access private */ private function _getPosition($positionObj) { $pos_ar = array(); $pos_ar[0] = (int) $positionObj['x0']; $pos_ar[1] = (int) $positionObj['y0']; $pos_ar[2] = (int) $positionObj['x1']; $pos_ar[3] = (int) $positionObj['y1']; $this->_logMessage(__METHOD__ . ' passed position \\n' . print_r($pos_ar, true)); // gets a position id by checkin if it's already in the DB // or adding a new position row if needed. if (($id = $this->_dh->get_id_position($pos_ar)) != -1) { // if a position is found in the posizione table, the use it $id_posizione = $id; } else { // add row to table "posizione" if (AMA_DB::isError($res = $this->_dh->add_position($pos_ar))) { $this->_logMessage(__METHOD__ . ' Error adding position! DB returned the following:'); $this->_logMessage(print_r($res, true)); return new AMA_Error($res->getMessage()); } else { // get id of position just added $id_posizione = $this->_dh->get_id_position($pos_ar); } } $this->_logMessage('Successfully got position_id=' . $id_posizione); return $id_posizione; }