private function clusterOccupation($occupation) { $community = OccupationCommunity::model()->findByAttributes(array('name' => $occupation)); Assert('$community != null'); return $community->id; }
/** * @param $PageCode * - string Page code of page to get property from. * - TRUE Get page property from global properties. * - FALSE Current page code specified using SetPageCode. * @param $PropertyLabel string Label of property. * @param $PropertyType string Name of the property type. * @param $Property array Property object. * @return bool Whether any properties were created. */ function InsertProperty($PageCode, $PropertyLabel, $PropertyType, $Property) { // Interpret special page code /// @pre (@a $PageCode === FALSE) => (PageCodeSet() === TRUE)) Assert('$PageCode !== FALSE || $this->PageCodeSet()'); if (FALSE === $PageCode) { $PageCode = $this->mPageCode; } $sql = 'INSERT INTO page_properties ( page_property_property_type_id, page_property_page_id, page_property_label, page_property_text) SELECT property_types.property_type_id,'; if (TRUE === $PageCode) { $sql .= 'NULL,'; } else { $sql .= 'pages.page_id,'; } $sql .= '?, ? FROM '; $bind_data = array($PropertyLabel, $Property['text']); if (TRUE !== $PageCode) { $sql .= 'pages,'; } $sql .= ' property_types WHERE '; if (TRUE !== $PageCode) { $sql .= 'pages.page_codename=? AND '; $bind_data[] = $PageCode; } $sql .= 'property_types.property_type_name=? ON DUPLICATE KEY UPDATE page_property_text=?'; $bind_data[] = $PropertyType; $bind_data[] = $Property['text']; $query = $this->db->query($sql, $bind_data); return $this->db->affected_rows() > 0; }