public function getItemByTitle($title) { $SQL_title = Convert::raw2sql($title); $item = DataObject::get_one('DataListItem', "\"ListID\" = {$this->ID} AND \"Title\" = '{$SQL_title}'"); if (!$item || !$item->exists()) { // create item $item = new DataListItem(); $item->ListID = $this->ID; $item->Title = $title; $item->write(); } return $item; }
protected function processRecord($record, $columnMap, &$results, $preview = false) { $class = $this->objectClass; $title = trim($record['Title']); $item = trim($record['ListItem']); $existingList = DataList::get_data_list($title); if (!$existingList) { $existingList = new DataList(); $existingList->Title = $title; $existingList->write(); } // now add the item to that list $existingItem = DataObject::get_one('DataListItem', '"Title"=\'' . Convert::raw2sql($item) . '\' AND "ListID" = ' . (int) $existingList->ID); if (!$existingItem) { $existingItem = new DataListItem(); $existingItem->Title = $item; $existingItem->ListID = $existingList->ID; $existingItem->write(); } }