<p>I've tested your code with a similar query in a local database and am getting the results you'd expect. So the code seems accurate. Aside from environmental variables that may be at play, the only part of the example code above that I see a potential issue with the line:</p>

<pre><code>$criteria-&gt;section = 'entryHandle'; 
</code></pre>

<p>It's unclear what you may mean by <code>entryHandle</code>.  This value should be the <code>sectionHandle</code>. If <code>entryHandle</code> means <code>slug</code>, then the <code>$criteria-&gt;section</code> may need to get updated to be <code>$criteria-&gt;slug = 'entryHandle';</code></p>

CC BY-SA 3.0
2015-08-15T20:05:10.743Z
2015-08-15T20:05:10.743Z
Ben Parizek
<p>I've noticed something odd and I can't find anything in the documentation.</p>

<p>I'm writing a plugin and when I use <code>ElementCriteriaModel</code> to find an existing entry like so:</p>

<pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
$criteria-&gt;section = 'entryHandle';
$criteria-&gt;title = 'The Title &amp; Stuff';
$existingEntry = $criteria-&gt;first();
</code></pre>

<p>The entry is not found, and I believe it's because of the punctuation. The entry is clearly in the <code>craft_content</code> table (with the exact title including punctuation). Is there some sort of processing I need to do before setting the title criterion?</p>

<p>Thanks!</p>

CC BY-SA 3.0
2015-08-15T03:00:26.813Z
Which character set and collation is your database using?
Steve Adams
CC BY-SA 3.0
2015-08-15T03:03:17.893Z
character set: UTF 8, collation: utf8_unicode_ci
ashley
CC BY-SA 3.0
2015-08-15T03:25:34.723Z
You might need to treat the ampersand as a special character. Try this and see what happens: $criteria->title =escapeParam("The Title & Stuff");  Just an untested guess.
Steve Adams
<elementcriteriamodel>
Problems with Punctuation in Title using ElementCriteriaModel
# Problems with Punctuation in Title using ElementCriteriaModel

(Asked by: username_0 on 2015-08-15)

I've noticed something odd and I can't find anything in the documentation.
I'm writing a plugin and when I use ElementCriteriaModel to find an existing entry like so:
$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->section = 'entryHandle';
$criteria->title = 'The Title & Stuff';
$existingEntry = $criteria->first();

The entry is not found, and I believe it's because of the punctuation. The entry is clearly in the craft_content table (with the exact title including punctuation). Is there some sort of processing I need to do before setting the title criterion?
Thanks!

**Tags:** elementcriteriamodel

> **Comments:**
> **username_1**: Which character set and collation is your database using?  
> **username_0**: character set: UTF 8, collation: utf8_unicode_ci  
> **username_1**: You might need to treat the ampersand as a special character. Try this and see what happens: $criteria->title =escapeParam("The Title & Stuff");  Just an untested guess.  

---

## 1 answers

### Answer by username_2 on 2015-08-15. Score: 1

I've tested your code with a similar query in a local database and am getting the results you'd expect. So the code seems accurate. Aside from environmental variables that may be at play, the only part of the example code above that I see a potential issue with the line:
$criteria->section = 'entryHandle'; 

It's unclear what you may mean by entryHandle.  This value should be the sectionHandle. If entryHandle means slug, then the $criteria->section may need to get updated to be $criteria->slug = 'entryHandle';


---

