| 
 | 
  Hadi Sharghi - 2016-02-27 19:12:00  
I've looked in provided file example.php and saw this line: 
    $rows=$db->fetch("SELECT * FROM my_table WHERE col1=?","s","12","Value1"); 
col1 = ? requires a value, but the parameters provided are 3. What's the meaning of three parameters? 
More explanation is really appreciated. 
 
Thanks, 
Hadi 
  
  Name Removed - 2016-02-27 21:47:02 -  In reply to message 1 from Hadi Sharghi 
Usage: 
 
$db->query($query,$data_types,$lengths,$value); 
$db->fetch($query,$data_types,$lengths,$value); 
 
 
Parameters: 
 
$query: SQL query to be prepared for execution 
 
$data_types: Data types to be binded for execution."s" for string, "i" for integer, "b" for bool.Each character is assigned to a value.No space between characters.For example: 
$db->query($query,"sib",$lengths,$value1,$value2,$value3); 
"s" is assigned to $value1 
"i" is assigned to $value2 
"b" is assigned to $value3 
 
$lengths: Lengths to be binded for execution.Each number is assigned to a value.Numbers are separated by ":".For example: 
$db->query($query,$data_types,"10:5:12",$value1,$value2,$value3); 
10 is assigned to $value1 
5 is assigned to $value2 
12 is assigned to $value3 
 
$value: Value to be binded for execution.You must pass the same number of values as the data types and lengths. 
 
 
If you don't need to bind parameters you may use: 
$db->fetch($query); 
 
 
 
 
Hope I helped.Let me know if you have more questions. 
 
 
  
  PipisCrew - 2016-02-28 17:32:56 -  In reply to message 2 from Name Removed 
Hi there,  
 
Nice class, please find my *static* PDO class + examples at http://bit.ly/1n8g16c 
 
keep up, magkako.. check also @ works > DB manager 
  
  Hadi Sharghi - 2016-02-29 10:29:30 -  In reply to message 2 from Name Removed 
Thanks for a comprehensive answer and examples, 
Didn't get what's the length parameter for?  
$db->query($query,$data_types,"10:5:12",$value1,$value2,$value3); 
 
length : 12 for a bool value? what does it mean? 
 
Regards, 
Hadi 
  
  Name Removed - 2016-02-29 12:54:39 -  In reply to message 4 from Hadi Sharghi 
According to php.net, "Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length.". 
 
In my opinion it's not that important, just put any value.BUT still the number of lengths, separated by ":", must be the same as the number of data types and values. 
 
 
  
  Name Removed - 2016-02-29 13:10:30 -  In reply to message 3 from PipisCrew 
Thanks Pipi! 
Nice name :p Congrats on your works. 
  
  Hadi Sharghi - 2016-03-01 05:26:37 -  In reply to message 5 from Name Removed 
Thanks man, 
Great job.  
 
Hadi 
  
  Name Removed - 2016-03-01 11:44:49 -  In reply to message 7 from Hadi Sharghi 
Thank you Hadi! :) 
  
   |