CodeIgniter Forums
using define in a SQL statement - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: using define in a SQL statement (/showthread.php?tid=83549)



using define in a SQL statement - richb201 - 10-02-2022

I am having trouble getting this to work. In index.php I have included
    //test temporary
    define ('TEMP_TEST', 'TEMPORARY');
//    define ('TEMP_TEST', '');

and in my model I have 
  $sql = "CREATE ".TEMP_TEST." TABLE ".$_SESSION['prefix']."key_temp
        SELECT sa.activity, a.risk,
              CASE WHEN
                                a.risk= 'HIGH' THEN 1
                                ELSE 1
              END AS qualified
        from activity a, standard_activities sa, relation r where a.email='$email' AND a.campaign='$_SESSION[campaign]' AND r.activity_id=a.id AND sa.standard_id=r.id";

I thought that TEMP_TEST would be replaced by TEMPORARY. It doesn't seem to work. Is TEMP_TEST not GLOBAL?


RE: using define in a SQL statement - kenjis - 10-02-2022

(10-02-2022, 05:48 PM)richb201 Wrote: I thought that TEMP_TEST would be replaced by TEMPORARY. It doesn't seem to work. Is TEMP_TEST not GLOBAL?

Yes, it is global.
TEMP_TEST should be replaced by TEMPORARY.