Welcome Guest, Not a member yet? Register   Sign In
need to pass email field value into variable

[eluser]Brad K Morse[/eluser]
model function: gets email of $venue_id = id

function getVenueChairEmail($venue_id) {
  $q = $this->db->select('email')->where('id',$venue_id)->get('venues');

Then I want to pass the email into the variable $to, like I am trying to do below

$to = $this->data_model->getVenueChairEmail($venue_id);

It is not passing anything into $to, tested by printing it out, empty.

I imagine its not as easy as that, any help is appreciated.

Have you tested the raw query on the database to see if it returns anything? According to your code, it looks like your query is:

SELECT email from venues WHERE id = $venue_id;

If you plug in a venue id and it doesn't work, then there's your problem.

If it does work, then you should look at the value of $venue_id before you try to pass it to the model.

[eluser]Greg Aker[/eluser]
You need to return from the model function.


public function get_venue_chair_email($venue_id)
    $qry = $this->db->select('email')
                    ->where('id', $venue_id)
    // We get a result?
    if ($qry->num_rows() === 0)
        return FALSE;
    return $qry->row('email');


$to = $this->data_model->get_venue_chair_email($venue_id)

if ($to === FALSE)
    // to failed, maybe time for an error.


[eluser]Brad K Morse[/eluser]
Thank you Greg! That did the trick, you're 2 for 2!

[eluser]Greg Aker[/eluser]
If you don't have it. get xdebug running on your dev environment. using var_dump with that installed, and you'll see all sorts of pretty things about your data. Smile

Theme © iAndrew 2016 - Forum software by © MyBB