title: Php Mysqli simple class method for INSERT, UPDATE, DELETE and Search
body: <p>I have the following code in my CRUD class   </p>
  
  <pre><code>//function to execute prepared statement query
  //$sql = select , insert, update and or delete query =&gt; insert into table(col,col,col,...col) values(?,?,?,...?);
  //$dataTypes = "ssidb", it could be any char in s=&gt;string, i=&gt;integer, d=&gt;double and b=&gt;blob data
  //$param = $val1,$val2,$val3,....$valn, this is an option coma separated values to bind with query
  public function dbQuery($sql,$dataTypes="",$param=""){
      try{
          $this-&gt;connect();
          $stmt = $this-&gt;con-&gt;stmt_init();
          $stmt = $this-&gt;con-&gt;prepare($sql);
          $stmt-&gt;bind_param($dataTypes, $param);          
          if($stmt-&gt;execute() === true){
              return true;    
              }
          else{
              return false;   
              }
          }catch(Exception $e){
              $this-&gt;errorMsg = $e-&gt;getMessage(); 
          }
          $this-&gt;closeConnection();
      }
  </code></pre>
  
  <p>I am calling this method from my index page like this:</p>
  
  <pre><code> if(isset($_POST['btnSearch'])){
   //search for some record with primary key
   $sno = intval($_POST['sno']);
   $sql = "SELECT sno,std_name,email,roll_number FROM table_1 WHERE sno = ?";
   $dTypes = "i";
   $params = $sno;
  if($db-&gt;dbQuery($sql,$dTypes,$params)){
      echo('Record exists');
      }
  else{
      echo('Record did not found'.$db-&gt;errorMsg);
      }
  }//search for record
  </code></pre>
  
  <p>//inserting values to table_1 table</p>
  
  <p>This always return true either there is any record exists or not?
  Whats going wrong with this code?</p>