title: How to solve error in CDb connection in Yii framework
body: <p><strong>I have an error when  trying to login to a Home page in Yii</strong></p>
  
  <p><em>This is error description</em></p>
  
  <p>CDbCommand не удалось исполнить SQL-запрос: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1. The SQL statement executed was: SELECT COUNT(*) FROM <code>documents</code> <code>t</code> LEFT JOIN docpaterns as p ON t.type = p.id WHERE p.required = 1 AND t.status = 1 AND t.user_id =</p>
  
  <p><em>This is my code</em></p>
  
  <pre><code>public function getDocsStatusNew() {
      // К новому модулю "документы"
      $reqDocPats = count(DocPatterns::model()&gt;findAllByAttributes(['required' =&gt; 1]));
  
      $reqDocs = new CActiveDataProvider(Documents::model(), [
          'criteria' =&gt; [
              'join' =&gt; 'LEFT JOIN docpaterns as p ON t.type = p.id',
              'condition' =&gt; 'p.required = 1 AND t.status = 1 AND t.user_id = ' . $this-&gt;id,
          ],
      ]);
  
      if ($reqDocPats == count($reqDocs-&gt;data)) {
          return true;
      } else {
          return false;
      }
  }
  </code></pre>