Skip to content

Instantly share code, notes, and snippets.

@FragsterAt
Created July 24, 2018 12:45
Show Gist options
  • Save FragsterAt/999b7e78a4e092bde0199a73051424dd to your computer and use it in GitHub Desktop.
Save FragsterAt/999b7e78a4e092bde0199a73051424dd to your computer and use it in GitHub Desktop.
<?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