I'm currently creating a plugin for craft and have stumbled across a slight problem. I'll try summarise of what I am doing and what I am trying to achieve.
So, I'm trying creating a plugin which will update entries within craft via an external API. I have managed to get the initial save to work using these following lines:
$entry = new EntryModel();
$entry->getContent()->title = $project->name;
$entry->sectionId = 10;
craft()->entries->saveEntry($entry);
The issue arises when I'm trying to update the model. Obviously, I don't want to duplicate entries.
I can get the entry using this line:
EntryRecord::model()->findById(45);
(this is just used for testing, eventually I will be getting the record via a custom variable).
What I'm trying to do here is update the title of this record, from what I can see this is stored in the craft_content table.
Basically what I'd like to do is something like :
EntryModel::model()->findByAttributes(array('title'=>$project->name);
So I can then update the content title of that row. I can see I can't do it this way, would you be able point me in the right direction?