title: PDO, check for empty string and don't update if empty
body: <p>If I run my function <code>edit_profile()</code> without any parameter, then empty strings are written in DB. If <code>$input['email']</code> is empty for example, I'd like <code>UPDATE</code> not to update this column.</p>
  
  <p>I tried to do:</p>
  
  <pre><code>SET email = IF(LENGTH(:email)=0, email, :email),
  </code></pre>
  
  <p>It didn't work, I'm not sure how to do same as above with PDO.</p>
  
  <pre><code>function edit_profile($input) {
      //
      $user_id = 1;
      //
      try {
      //
  
          $conn = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USERNAME, DB_PASSWORD);
          $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
          $stmt = $conn-&gt;prepare('UPDATE users SET
                                      email = :email,
                                      password = :password,
                                      name_surname = :name_surname,
                                      age = :age,
                                      sex = :sex,
                                      education = :education,
                                      avatar = :avatar
                                      WHERE id = :id');
  
  
                  $stmt-&gt;execute(array(
                      ':id'           =&gt; $user_id,
                      ':email'        =&gt; $input['email'],
                      ':password'     =&gt; $input['password'],
                      ':name_surname' =&gt; $input['name_surname'],
                      ':age'          =&gt; $input['age'],
                      ':sex'          =&gt; $input['sex'],
                      ':education'    =&gt; $input['education'],
                      ':avatar'       =&gt; $input['avatar']
                  ));
  
  
          echo $stmt-&gt;rowCount(); // 1
      //
      } catch(PDOException $e) {
          echo 'ERROR: ' . $e-&gt;getMessage();
      }
      //
  }
  edit_profile();
  </code></pre>