Created
July 24, 2018 12:45
-
-
Save FragsterAt/999b7e78a4e092bde0199a73051424dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Description of DBStatement | |
* | |
* @author antonio | |
*/ | |
class DBStatement { | |
/* @var $statement mysqli_stmnt */ | |
protected $statement; | |
public function __construct($query) { | |
$db = DB::getConnection(); | |
$this->statement = $db->prepare($query); | |
if (!$this->statement) | |
echo $db->error; | |
} | |
function bindParams() { | |
$args = array ($this->statement); | |
$types = ''; | |
$values = array(); | |
for($i=0; $i< func_num_args(); $i++) { | |
$value = func_get_arg($i); | |
if (is_int($value)) { | |
$types .= 'i'; | |
} elseif (is_double($value)) { | |
$types .= 'i'; | |
} elseif (is_double($value)) { | |
$types .= 'd'; | |
} elseif (is_string ($value)) { | |
$types .= 's'; | |
} else { // все равно как строка пусть передается, потому как определить, что это бинарные жданные мы не можем | |
$types .= 's'; | |
} | |
$values[] = &$value; | |
} | |
$args[]=$types; | |
call_user_func_array('mysqli_stmt_bind_param', array_merge($args, $values)); | |
var_dump($this->statement); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment