Welcome Guest, Not a member yet? Register   Sign In
get data from database as obj or array
#1

[eluser]ranjitbd[/eluser]
//this is the controller

<?php
class Holiday extends Controller {


function getDestination()
{
$data = array();
$this->load->model($this->config->item('generalModel'), 'getDes',TRUE);
$data['desPack']=$this->getDes->desPackName();
print_r($data);
// echo $data['destination_name']; //its not executing showing error
exit;
}

}
?>

//this is the model

<?php
class User_model extends Model
{
function User_model()
{
parent::Model();
}

function desPackName()
{
$query = $this->db->get('destination');
return $query->result();
}
}
?>

//output of this code

Array ( [desPack] => Array ( [0] => stdClass Object ( [destination_id] => 1 [destination_name] => Around Dhaka [destination_description] => Dhaka is a magnificent city, where people & history are thousand years old. [destination_image] => dhaka.jpg [remarks] => ) [1] => stdClass Object ( [destination_id] => 2 [destination_name] => Around Chittagong [destination_description] => Chittagong is a magnificent city, where people & history are thousand years old. [destination_image] => chittagong.jpg [remarks] => ) [2] => stdClass Object ( [destination_id] => 3 [destination_name] => Aroung Coxs Bazar [destination_description] => Coxs Bazar is a magnificent city, where people & history are thousand years old. [destination_image] => coxsbazar.jpg [remarks] => ) [3] => stdClass Object ( [destination_id] => 4 [destination_name] => Around Sylhet [destination_description] => Sylhet is a magnificent city, where people & history are thousand years old. [destination_image] => sylhet.jpg [remarks] => ) [4] => stdClass Object ( [destination_id] => 5 [destination_name] => Around Khulna [destination_description] => Khulna is a magnificent city, where people & history are thousand years old. [destination_image] => khulna.jpg [remarks] => ) [5] => stdClass Object ( [destination_id] => 6 [destination_name] => Hill District [destination_description] => Dhaka is a magnificent city, where people & history are thousand years old. [destination_image] => hills.jpg [remarks] => ) ) )


//i have to execute the following line of code
// echo $data['destination_name']; //its not executing showing error
//the output should be

Around Dhaka


Messages In This Thread
get data from database as obj or array - by El Forum - 08-29-2009, 04:56 AM
get data from database as obj or array - by El Forum - 08-29-2009, 06:30 AM
get data from database as obj or array - by El Forum - 08-29-2009, 09:11 AM
get data from database as obj or array - by El Forum - 08-30-2009, 12:00 AM
get data from database as obj or array - by El Forum - 08-30-2009, 12:32 AM
get data from database as obj or array - by El Forum - 08-30-2009, 12:39 AM
get data from database as obj or array - by El Forum - 08-30-2009, 06:55 AM
get data from database as obj or array - by El Forum - 08-30-2009, 07:23 AM
get data from database as obj or array - by El Forum - 08-30-2009, 08:07 AM
get data from database as obj or array - by El Forum - 08-30-2009, 08:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB