Jump to content

Mysql num_rows shows 3 results, fetch array outputs only 2.


Ivan Ivković

Recommended Posts

Hmm... Odd indeed. Might be the template engine that messed it up, or something else. Did you try a step-by-step debugging on this one, perchance?

 

Anyway, nice to hear that you solved it, even though the solution was sub-optimal. :)

Hmm... Odd indeed. Might be the template engine that messed it up, or something else. Did you try a step-by-step debugging on this one, perchance?

 

Anyway, nice to hear that you solved it, even though the solution was sub-optimal. :)

 

All my template class does is recieve the data ( template -> any_attribute ) and loads the template (loadTemplate).

It does not change the variable/mysqli result object in any way, why should it? Damn strange.

 

<?php

class Template{

public $vars;
private $registry;

public function __construct($registry){
	$this -> registry = $registry;
}

public function __set($index, $value){
	$this -> vars[$index] = $value;
}

public function loadTemplate($tpl){

	$path = $this -> registry -> router -> dir_path . '/' . $tpl . '.php';

	if(file_exists($path) == false){
		throw new Exception('Template not found in '. $path);
		return false;
	}

	if(!empty($this -> vars)){
		foreach($this -> vars as $key => $value){
			$$key = $value;
		}
	}

	include($path);
}

}

 

I do not see the problem here. Do you maybe?

 

About sub-optimal. Yea I know.. :/ Nothing's perfect I guess.

Might be the foreach, but again: I cannot say anything with any degree of certainty, without having gone through a step-by-step debug. Only then will I be able to see exactly where it happens, and thus find out why.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.