I'm working on a site with CodeIgniter and can't figure out why my function is not returning the array, this should be simple.
I did a dump in the model before returning just to see if it was formatted and had the data (which is does). The issue seems to be in the controller the function is not returning the data and in the view properties is null.
What is happening with CI or PHP that might cause this?
Controller:
function galleryManagement()
{
if (! $this->session->userdata('is_admin'))
{
redirect('admin/index');
}
else
{
/*
$selectedProperty = $this->input->post('selectedProperty');
switch ($selectedProperty)
{
case "westgate":
$selectedID = '1';
break;
case "prospector436":
$selectedID = '2';
break;
case "prospector437":
$selectedID = '3';
break;
case "prospectorcombo":
$selectedID = '4';
break;
default:
$selectedID = '-1';
}
if ($selectedID != '-1')
{
*/
$this->load->model('admin_model');
$propertyObj = $this->admin_model->getProperties();
$data['properties'] = $propertyObj;
$data['propertyID'] = $selectedID;
$data['galleryObj'] = $this->admin_model->getGallery($selectedProperty);
//$data['textarea'] = array ( 'name' => 'altText', 'style' => "width: 320px; height: 36px;" );
$this->load->view('db_site/admin_gallery_view', $data);
/*
}
else
{
$this->load->model('admin_model');
$data['propertiesObj'] = $this->admin_model->getProperties();
$data['propertyID'] = $selectedID;
$this->load->view('db_site/admin_gallery_view', $data);
}
*/
}
}
Model:
function getProperties()
{
$this->db->select('property_id, name');
$this->db->from('property');
$q = $this->db->get();
if ($q->num_rows != 0)
{
$propertiesObj = $q->result();
foreach ($propertiesObj as $property)
{
$properties[$property->name] = $property->property_id;
}
echo "Model Dump: ";
var_dump($properties);
return $properties;
}
else
{
return false;
}
}
View:
<?php
var_dump($properties);
echo form_open('admin/galleryManagement');
echo "<p>Property: " . form_dropdown('selectedProperty', $properties) . "</p>";
echo form_submit('select', 'Select');
?>