Assign value from SQL to variable |
Hi guys!
I have a very simple question. I would like to assign SQL-query result (which is only 1 row and 1 column) to my variable, and when make calculations with them. This is SQL select query, which should be assigned to variable $timezone: Code: 'SELECT gtm FROM wh_rates WHERE (city_id = "'.$sity_id.'" OR city_id_en = "'.$sity_id.'") LIMIT 1' This is why I need variable $timezone (to make it clear for you): Code: $current_day = gmdate("N", time() + 3600*($timezone+date("I"))); Can anybody help me?
@dmitrykanaev,
1st question...Have you tested the query in the database to make sure that it works? 2nd question...What is the default value if for some reason your select query returns null? More questions...Are you returning just the value from the model to the variable $timezone? What is the name of the model that should be returning the variable? What is an example gtm value that you are expecting? My suggested solution is as follows... CONTROLLER (statement in controller): PHP Code: // call model method to get timezone value from database based on $sity_id MODEL (Model_timezone with a get_timezone method): PHP Code: /** |
Welcome Guest, Not a member yet? Register Sign In |