title: using prepared statements and dynamic param in mysqli
body: <p>I'm using a prepared statement and these functions are part of a mysqli class  .They work well for singl condition But do not right answer for multiple condition like this:</p>
  
  <pre><code>SelectByOrderCondi('user','username=? AND name=? AND email=? ' , $Array )
  </code></pre>
  
  <p>Here's my functions :</p>
  
  <pre><code>public function SelectByOrderCondi($Table_Name, $Conditions='' ,$Array_Conditions_Limit=null, $OrderBy='', $Limit='', $Selected_Fields='*')
  {
      $Query = "SELECT ".$Selected_Fields." FROM ".$Table_Name;
      if(!empty($Conditions))
          $Query .= " WHERE ".$Conditions;
      if(!empty($OrderBy))
          $Query .= " ORDER BY ".$OrderBy;
      if(!empty($Limit))
          $Query .= " LIMIT ".$Limit;
  
      $Statment = $this-&gt;ConnectionResult-&gt;prepare($Query);
      if(isset($Array_Conditions_Limit)  )
       {
          $Statment = $this-&gt;DynamicBindVariables($Statment, $Array_Conditions_Limit);
          $Statment-&gt;execute();
          return $Statment-&gt;get_result();
       }
       else
          return false ;
  
  }
  </code></pre>
  
  <p>Add my class this function:</p>
  
  <pre><code>Private function GetType($Item)
  {
      switch (gettype($Item)) {
          case 'NULL':
          case 'string':
              return 's';
              break;
  
          case 'integer':
              return 'i';
              break;
  
          case 'blob':
              return 'b';
              break;
  
          case 'double':
              return 'd';
              break;
      }
      return '';
  }
  </code></pre>
  
  <p>and change DynamicBindVariables functions as follows:</p>
  
  <pre><code>public function DynamicBindVariables($Statment, $Params)
  {
      if (is_array($Params) &amp;&amp; $Params != null)
      {
          // Generate the Type String (eg: 'issisd')
          $Types = '';
          foreach($Params as $Param)
          {
              $Types .= $this-&gt;GetType($Param);
          }
          // Add the Type String as the first Parameter
          $Bind_names[] = $Types;
  
          // Loop thru the given Parameters
          for ($i=0; $i&lt;count($Params);$i++)
          {
              $Bind_name = 'bind' . $i;
              // Add the Parameter to the variable 
              $$Bind_name = $Params[$i];
              // Associate the Variable as an Element in the Array
              $Bind_names[] = &amp;$$Bind_name;
          }
          // Call the Function bind_param with dynamic Parameters
          call_user_func_array(array($Statment,'bind_param'), $Bind_names);
      }
      else
      {
          $Types .= $this-&gt;GetType($Param);
          $Statment-&gt;bind_param($Types ,$Params);
      }
  
      return $Statment;
  }
  </code></pre>
  
  <p>Now it works properly</p>