Welcome Guest, Not a member yet? Register   Sign In
Undefined valuable
#11

(05-09-2017, 01:07 AM)neuron Wrote: in get_school method you are returning object of row objects, you need to fetch only one row. 
update your method:
PHP Code:
public function get_school() {
 
  $query $this->db->query("SELECT sname FROM setting");
if(
$query){
 return 
$query->row();
}
 
 return false//or return empty array


use print_r or var_dump functions for debugging your code

hey any other suggestion, am really stack
Reply
#12

send us your settings table picture.

you can connect to your db using mysql workbench connect to your db and then send us view of your settings table
Reply
#13

(This post was last modified: 05-11-2017, 09:28 AM by xenomorph1030.)

Are you new to CodeIgniter? I can understand not knowing where things go.

What Insite posted has instructions. You place that code into a new helper file (or existing if you want). You have to load that helper or add it to the autoloader. Then you call it like you did with var_dump except using varDebug.
Reply
#14

(05-11-2017, 04:28 AM)kayinja.denis Wrote:
(05-10-2017, 12:06 PM)InsiteFX Wrote: Here is a nice method to format var_dump values.

PHP Code:
/**
 * varDebug Helper - place in a helper file.
 * 
 * Formats the output of var_dump();
 * 
 */
if ( ! function_exists('varDebug'))
{
    
/**
     * Debug Helper
     * ----------------------------------------------------------------------------
     * 
     * Outputs the given variable(s) with color formatting and location
     * 
     * UUSAGE: varDebug(array);
     *
     * @param    mixed    - variables to be output
     */
    
function varDebug()
    {
        list(
$callee) = debug_backtrace();

        
$arguments func_get_args();

        
$total_arguments func_num_args();

        echo 
'<div><fieldset style="background: #fefefe !important; border:1px red solid; padding:15px">';
        echo 
'<legend style="background:lightgrey; padding:5px;">'.$callee['file'].' @line: '.$callee['line'].'</legend><pre><code>';

        
$i 0;
        foreach (
$arguments as $argument)
        {
            echo 
'<strong>Debug #'.++$i.' of '.$total_arguments.'</strong>: '.'<br>';
            
var_dump($argument);
        }

        echo 
"</code></pre></fieldset><div><br>";
        exit;
    }


Will make it easier to read in the forum's hers.
bro i don't understand how to use your function...

You just pass the array into it just like var_debug, place the method into a CodeIgniter helper file and autoload it,
then just call it like any other method varDebug(your_array or query);
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#15

Well guys thanks I got it to work
changed this 
PHP Code:
public function get_school()
 
    {
 
        $this->db->select('*');
 
        $this->db->from('setting');
 
        return $this->db->get()->result_array();
 
    

 to 
PHP Code:
function get_school($id) {
        
$compress = array();
        
$query $this->db->get('setting');
        foreach (
$query->result() as $row) {
         
   $compress[$row->fieldoption] = $row->value;
        }
        return (object) 
$compress;
    } 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB