Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // THIS IS REALLY REALLY ROUGH EXPERIMENTAL CODE
- // CURRENT ERRORS - Fatal error: Cannot pass parameter 2 by reference in C:\xampp\htdocs\wcx\admin\test.php on line 92
- // USUALLY $a='1' etc fixes this problem
- // Using $a='3',$b='4',$c='5',$d='7',$e='8' in bind_param works fine but when passed in as $where.. ERROR!
- // AUTO BIND FUNCTION
- function getBindParams($params) {
- if ($params != null) {
- $types = '';
- foreach ($params as $param) {
- if (is_int($param)) {
- $types .= 'i';
- }
- elseif (is_float($param)) {
- $types .= 'd';
- }
- elseif (is_string($param)) {
- $types .= 's';
- }
- else {
- $types .= 'b';
- }
- }
- }
- $bind_names = array();
- $types = array($types);
- for ($i=0; $i<count($params);$i++) {
- //$types = $params[$i];
- }
- // RETURN THE TYPES
- foreach($types as $type) {
- return $type;
- }
- }
- // TEMP ARRAY
- $params = array('3','4','5','7','8');
- // TEMP LETTER ARRAY FOR VARS
- $letters = array('a', 'b', 'c', 'd', 'e');
- $types = '';
- $wheres = '';
- foreach($params as $index => $param) {
- $types .= '?';
- if($index+1 !== count($params)) {
- $types .= ',';
- }
- }
- //$letters = array($letters);
- //foreach($letters as $letter) {
- //$letter = $letter;
- //."'". $where . "'"
- // ASSIGN VALUES TO A VARIABLE AUTOMATICALLY
- foreach($params as $index => $where) {
- $wheres .= '$' . array_pop($letters) .'='."'". $where . "'";
- if($index+1 !== count($params)) {
- $wheres .= ',';
- }
- }
- //}
- $bind_names = array();
- $types = array($types);
- $wheres = array($wheres);
- foreach($types as $type) {
- $type = $type;
- }
- foreach($wheres as $where) {
- $where = $where;
- }
- //print_r($where);
- //$where = implode(',',$where);
- //"','", $myArray) . "'"
- //$where = implode("','", $where . "'");
- $query = 'SELECT article_id FROM wcx_articles WHERE article_id IN ('. $type .')';
- //$stmt = $backend->prepareIt($query);
- echo $query.'<br />';
- echo $where.'<br />';
- $stmt = $backend->prepareIt('SELECT article_id FROM wcx_articles WHERE article_id IN ('. $type .')');
- //echo $stmt;
- $bindParams = getBindParams($params);
- echo $bindParams.'<br />';
- //$where = explode(',',$where);
- print_r($where);
- //echo $where;
- //call_user_func_array(array($stmt,'bind_param'),$params);
- // $where would essentially look like this!
- //$a='3',$b='4',$c='5',$d='7',$e='8'
- // ATTEMPT TO PASS THE VALUES IN TO BIND_PARAM +1 needed to match number of binds
- $stmt->bind_param($bindParams, $where+1);
- $stmt->execute();
- $stmt->bind_result($result);
- print_r($stmt);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement