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. :)

 

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.