Answers.Body: <p>As per the (new) <a href="http://buildwithcraft.com/docs/plugins/working-with-elements">"Working with Elements"</a> guide from the docs, it works the same as from your templates.</p>
  
  <blockquote>
    <p>The actual list of available parameters depends on the element type. They are identical to the parameters available to your templates.</p>
  </blockquote>
  
  <p>So this template example:</p>
  
  <pre><code>{% craft.entries.section('news').myPlaintextField('xyz').myLightswitchField(1) %}
  </code></pre>
  
  <p>Works from your plugin like so:</p>
  
  <pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
  $criteria-&gt;section            = 'news';
  $criteria-&gt;myPlaintextField   = 'xyz';
  $criteria-&gt;myLightswitchField = 1;
  </code></pre>
  
  <p>Using custom field parameters is a fast and reliable solution if you are looking for EXACT matches. I would only use the <code>search</code> parameter if there's no other solution.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-16T12:35:46.773Z
Answers.LastActivityDate: 2014-12-16T12:35:46.773Z
Answers.UserDisplayName: carlcs
Answers.Body: <p>You can use the a special search format.</p>
  
  <pre class="lang-php prettyprint-override"><code>$criteria-&gt; search = 'fieldHandle:searchstring';
  </code></pre>
  
  <p>Learn more about <a href="http://buildwithcraft.com/docs/searching" rel="noreferrer">searching</a></p>
  
  <p>Hope that helps!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-16T08:52:17.070Z
Answers.LastActivityDate: 2014-07-16T08:52:17.070Z
Answers.UserDisplayName: Selvin Ortiz
Answers.Body: <p>Try something like this. Remember to check the status. </p>
  
  <pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
  $criteria-&gt;slug = $slug;
  $criteria-&gt;status = NULL;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-16T10:22:08.157Z
Answers.LastActivityDate: 2014-12-16T10:22:08.157Z
Answers.UserDisplayName: David A McInnis
Body: <p>I'm looking at making a plugin and need to search news entries.
  I can use:</p>
  
  <pre class="lang-php prettyprint-override"><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
  $criteria-&gt;section = 'news';
  $find = $criteria-&gt;find();
  </code></pre>
  
  <p>However, I want to add a criteria where I search a specific field, for example: <code>fieldabc = 'zyx'</code></p>
  
  <p>What is the correct syntax for this?</p>
  
  <p>Thanks!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-16T07:07:06.730Z
Comments.Text: I see I can use: $criteria->search = 'zyx'; which would suffice, but is there a way to target it to a field ?
Comments.UserDisplayName: Anthony
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-16T09:06:46.800Z
Comments.Text: Hey Anthony, great question! Can you update the title to something a little more descriptive like "How to search for a specific field using getCriteria"? Thanks!
Comments.UserDisplayName: Jason McCallister
Tags: <plugin-development><elementcriteriamodel>
Title: How to search for a specific field using getCriteria()?
ThreadText: # How to search for a specific field using getCriteria()?
  
  (Asked by: username_0 on 2014-07-16)
  
  I'm looking at making a plugin and need to search news entries.
  I can use:
  
  ```php
  $criteria = craft()->elements->getCriteria(ElementType::Entry);
  $criteria->section = 'news';
  $find = $criteria->find();
  
  ```
  
  However, I want to add a criteria where I search a specific field, for example: `fieldabc = 'zyx'`
  
  What is the correct syntax for this?
  
  Thanks!
  
  **Tags:** plugin-development, elementcriteriamodel
  
  > **Comments:**
  > **username_0**: I see I can use: $criteria->search = 'zyx'; which would suffice, but is there a way to target it to a field ?  
  > **username_1**: Hey username_0, great question! Can you update the title to something a little more descriptive like "How to search for a specific field using getCriteria"? Thanks!  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2014-12-16. Score: 10
  
  As per the (new) ["Working with Elements"](http://buildwithcraft.com/docs/plugins/working-with-elements) guide from the docs, it works the same as from your templates.
  
  > The actual list of available parameters depends on the element type. They are identical to the parameters available to your templates.
  
  So this template example:
  
  ```
  {% craft.entries.section('news').myPlaintextField('xyz').myLightswitchField(1) %}
  
  ```
  
  Works from your plugin like so:
  
  ```
  $criteria = craft()->elements->getCriteria(ElementType::Entry);
  $criteria->section            = 'news';
  $criteria->myPlaintextField   = 'xyz';
  $criteria->myLightswitchField = 1;
  
  ```
  
  Using custom field parameters is a fast and reliable solution if you are looking for EXACT matches. I would only use the `search` parameter if there's no other solution.
  
  
  ---
  
  ### Answer by username_3 on 2014-07-16. Score: 7
  
  You can use the a special search format.
  
  ```php
  $criteria-> search = 'fieldHandle:searchstring';
  
  ```
  
  Learn more about [searching](http://buildwithcraft.com/docs/searching)
  
  Hope that helps!
  
  
  ---
  
  ### Answer by username_4 on 2014-12-16. Score: 1
  
  Try something like this. Remember to check the status.
  
  ```
  $criteria = craft()->elements->getCriteria(ElementType::Entry);
  $criteria->slug = $slug;
  $criteria->status = NULL;
  
  ```
  
  
  ---
  
  