Query in php on CodeigniterHow can I prevent SQL injection in PHP?Deleting an element from an array in PHPConvert HTML + CSS to PDF with PHP?startsWith() and endsWith() functions in PHPHow do I get PHP errors to display?Can I try/catch a warning?How do you parse and process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

What could prevent players from leaving an island?

How to check a file was encrypted (really & correctly)

How to halve redstone signal strength?

Where in ש״ס who one find the adage, “He who suggests the idea should carry it out”?

Why does putting a dot after the URL remove login information?

Colleagues speaking another language and it impacts work

Why do private jets such as Gulfstream fly higher than other civilian jets?

What word best describes someone who likes to do everything on his own?

Based on what criteria do you add/not add icons to labels within a toolbar?

How to approach protecting my code as a research assistant? Should I be worried in the first place?

Capacitors with a "/" on schematic

Why is Chromosome 1 called Chromosome 1?

How do these cubesats' whip antennas work?

Why should I "believe in" weak solutions to PDEs?

Why ReLU function is not differentiable at 0?

ESTA declined to the US

Is this cheap "air conditioner" able to cool a room?

Is the Folding Boat truly seaworthy?

Can ads on a page read my password?

Differentiability of operator norm

Can I enter a rental property without giving notice if I'm afraid a tenant may be hurt?

Cobb-Douglas production function with expenditures rather than units

Unexpected route on a flight from USA to Europe

Does a 4 bladed prop have almost twice the thrust of a 2 bladed prop?



Query in php on Codeigniter


How can I prevent SQL injection in PHP?Deleting an element from an array in PHPConvert HTML + CSS to PDF with PHP?startsWith() and endsWith() functions in PHPHow do I get PHP errors to display?Can I try/catch a warning?How do you parse and process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I can't use my query in php when i use codeigniter.
I think that it's all ok but my code doesn't work.
What is it wrong ?



I need to cofront two parametres.



I have a table and i need colonn3



Models:



 function get_colonn3($data){
$this->db->select("table.colonn3");
$this->db->where("table.colonn3",$data);
return $this->db->get("table.colonn3")->result_array();


Controller:



$colonn3_exsist = $this->my_model->get_colonn3($data)

if($colonn3_exsist):
echo "ok";
endif;









share|improve this question



















  • 3





    what is the value of $data is your table name table?

    – Masivuye Cokile
    Mar 26 at 12:49


















0















I can't use my query in php when i use codeigniter.
I think that it's all ok but my code doesn't work.
What is it wrong ?



I need to cofront two parametres.



I have a table and i need colonn3



Models:



 function get_colonn3($data){
$this->db->select("table.colonn3");
$this->db->where("table.colonn3",$data);
return $this->db->get("table.colonn3")->result_array();


Controller:



$colonn3_exsist = $this->my_model->get_colonn3($data)

if($colonn3_exsist):
echo "ok";
endif;









share|improve this question



















  • 3





    what is the value of $data is your table name table?

    – Masivuye Cokile
    Mar 26 at 12:49














0












0








0








I can't use my query in php when i use codeigniter.
I think that it's all ok but my code doesn't work.
What is it wrong ?



I need to cofront two parametres.



I have a table and i need colonn3



Models:



 function get_colonn3($data){
$this->db->select("table.colonn3");
$this->db->where("table.colonn3",$data);
return $this->db->get("table.colonn3")->result_array();


Controller:



$colonn3_exsist = $this->my_model->get_colonn3($data)

if($colonn3_exsist):
echo "ok";
endif;









share|improve this question














I can't use my query in php when i use codeigniter.
I think that it's all ok but my code doesn't work.
What is it wrong ?



I need to cofront two parametres.



I have a table and i need colonn3



Models:



 function get_colonn3($data){
$this->db->select("table.colonn3");
$this->db->where("table.colonn3",$data);
return $this->db->get("table.colonn3")->result_array();


Controller:



$colonn3_exsist = $this->my_model->get_colonn3($data)

if($colonn3_exsist):
echo "ok";
endif;






php mysql codeigniter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 12:43









Phantom MoorePhantom Moore

226 bronze badges




226 bronze badges










  • 3





    what is the value of $data is your table name table?

    – Masivuye Cokile
    Mar 26 at 12:49













  • 3





    what is the value of $data is your table name table?

    – Masivuye Cokile
    Mar 26 at 12:49








3




3





what is the value of $data is your table name table?

– Masivuye Cokile
Mar 26 at 12:49






what is the value of $data is your table name table?

– Masivuye Cokile
Mar 26 at 12:49













5 Answers
5






active

oldest

votes


















0














Remove table.colon3 from get(), maybe it will work



return $this->db->get()->result_array();





share|improve this answer




















  • 1





    Not work :( thanks!

    – Phantom Moore
    Mar 26 at 13:36


















0














I believe is because you're passing the table name to the where statement and it expects a column.



CodeIgniter where documentation



function get_colonn3($data) 
$this->db->select("table.colonn3");

$this->db->where("colonn3", $data);

return $this->db->get("table")->result_array();



They also allow you to pass an array to the where parameters too:



function get_colonn3($data) 
$this->db->select("table.colonn3");

$this->db->where([
"colonn3" => $data
]);

return $this->db->get("table")->result_array();



CI also allows you to chain DB functions like so:



function get_colonn3($data) 
$this->db->select("table.colonn3")
->where([
"colonn3" => $data
]);

return $this->db->get("table")->result_array();






share|improve this answer




















  • 1





    And in controller ? How use colonn3 ?

    – Phantom Moore
    Mar 26 at 13:36


















0














try this:



//model



function get_colonn3($data){
$this->db->select("colonn3");
$this->db->where("colonn3",$data);
return $this->db->get("table")->result_array();


//controller



$colonn3_exsist = $this->my_model->get_colonn3($data)
if($colonn3_exsist>0)
echo"ok";






share|improve this answer
































    0














    You are passing the value to WHERE in a wrong way. You have to pass the values in an array without passing the table name.



    You have to pass the array in WHERE clause like this if you have more than one parameter to compare from Database:



    function get_colonn3($para1,$para2)
    $this->db->select("table.colonn3");
    $this->db->where(['columnname1' => $para1, 'columnname2' => $para2]);
    return $this->db->get("table.colonn3")->result_array();



    If you have only one parameter to compare then you can use this:



    function get_colonn3($para1)
    $this->db->select("table.colonn3");
    $this->db->where('columnname1',$para1);
    return $this->db->get("table.colonn3")->result_array();






    share|improve this answer
































      0














      Model



       function get_colonn3($data)
      return $this->db->select("table.colonn3 as col3")->from('table')->where(['table.colonn3' => $data])->get()->row()->col3;



      Controller



      $colonn3 = $this->my_model->get_colonn3($data)

      if(!empty($colonn3)):
      echo "ok";
      endif;





      share|improve this answer



























        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55357523%2fquery-in-php-on-codeigniter%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        0














        Remove table.colon3 from get(), maybe it will work



        return $this->db->get()->result_array();





        share|improve this answer




















        • 1





          Not work :( thanks!

          – Phantom Moore
          Mar 26 at 13:36















        0














        Remove table.colon3 from get(), maybe it will work



        return $this->db->get()->result_array();





        share|improve this answer




















        • 1





          Not work :( thanks!

          – Phantom Moore
          Mar 26 at 13:36













        0












        0








        0







        Remove table.colon3 from get(), maybe it will work



        return $this->db->get()->result_array();





        share|improve this answer













        Remove table.colon3 from get(), maybe it will work



        return $this->db->get()->result_array();






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 26 at 13:06









        Ikram KhizerIkram Khizer

        398 bronze badges




        398 bronze badges










        • 1





          Not work :( thanks!

          – Phantom Moore
          Mar 26 at 13:36












        • 1





          Not work :( thanks!

          – Phantom Moore
          Mar 26 at 13:36







        1




        1





        Not work :( thanks!

        – Phantom Moore
        Mar 26 at 13:36





        Not work :( thanks!

        – Phantom Moore
        Mar 26 at 13:36













        0














        I believe is because you're passing the table name to the where statement and it expects a column.



        CodeIgniter where documentation



        function get_colonn3($data) 
        $this->db->select("table.colonn3");

        $this->db->where("colonn3", $data);

        return $this->db->get("table")->result_array();



        They also allow you to pass an array to the where parameters too:



        function get_colonn3($data) 
        $this->db->select("table.colonn3");

        $this->db->where([
        "colonn3" => $data
        ]);

        return $this->db->get("table")->result_array();



        CI also allows you to chain DB functions like so:



        function get_colonn3($data) 
        $this->db->select("table.colonn3")
        ->where([
        "colonn3" => $data
        ]);

        return $this->db->get("table")->result_array();






        share|improve this answer




















        • 1





          And in controller ? How use colonn3 ?

          – Phantom Moore
          Mar 26 at 13:36















        0














        I believe is because you're passing the table name to the where statement and it expects a column.



        CodeIgniter where documentation



        function get_colonn3($data) 
        $this->db->select("table.colonn3");

        $this->db->where("colonn3", $data);

        return $this->db->get("table")->result_array();



        They also allow you to pass an array to the where parameters too:



        function get_colonn3($data) 
        $this->db->select("table.colonn3");

        $this->db->where([
        "colonn3" => $data
        ]);

        return $this->db->get("table")->result_array();



        CI also allows you to chain DB functions like so:



        function get_colonn3($data) 
        $this->db->select("table.colonn3")
        ->where([
        "colonn3" => $data
        ]);

        return $this->db->get("table")->result_array();






        share|improve this answer




















        • 1





          And in controller ? How use colonn3 ?

          – Phantom Moore
          Mar 26 at 13:36













        0












        0








        0







        I believe is because you're passing the table name to the where statement and it expects a column.



        CodeIgniter where documentation



        function get_colonn3($data) 
        $this->db->select("table.colonn3");

        $this->db->where("colonn3", $data);

        return $this->db->get("table")->result_array();



        They also allow you to pass an array to the where parameters too:



        function get_colonn3($data) 
        $this->db->select("table.colonn3");

        $this->db->where([
        "colonn3" => $data
        ]);

        return $this->db->get("table")->result_array();



        CI also allows you to chain DB functions like so:



        function get_colonn3($data) 
        $this->db->select("table.colonn3")
        ->where([
        "colonn3" => $data
        ]);

        return $this->db->get("table")->result_array();






        share|improve this answer













        I believe is because you're passing the table name to the where statement and it expects a column.



        CodeIgniter where documentation



        function get_colonn3($data) 
        $this->db->select("table.colonn3");

        $this->db->where("colonn3", $data);

        return $this->db->get("table")->result_array();



        They also allow you to pass an array to the where parameters too:



        function get_colonn3($data) 
        $this->db->select("table.colonn3");

        $this->db->where([
        "colonn3" => $data
        ]);

        return $this->db->get("table")->result_array();



        CI also allows you to chain DB functions like so:



        function get_colonn3($data) 
        $this->db->select("table.colonn3")
        ->where([
        "colonn3" => $data
        ]);

        return $this->db->get("table")->result_array();







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 26 at 13:07









        B3noneB3none

        17512 bronze badges




        17512 bronze badges










        • 1





          And in controller ? How use colonn3 ?

          – Phantom Moore
          Mar 26 at 13:36












        • 1





          And in controller ? How use colonn3 ?

          – Phantom Moore
          Mar 26 at 13:36







        1




        1





        And in controller ? How use colonn3 ?

        – Phantom Moore
        Mar 26 at 13:36





        And in controller ? How use colonn3 ?

        – Phantom Moore
        Mar 26 at 13:36











        0














        try this:



        //model



        function get_colonn3($data){
        $this->db->select("colonn3");
        $this->db->where("colonn3",$data);
        return $this->db->get("table")->result_array();


        //controller



        $colonn3_exsist = $this->my_model->get_colonn3($data)
        if($colonn3_exsist>0)
        echo"ok";






        share|improve this answer





























          0














          try this:



          //model



          function get_colonn3($data){
          $this->db->select("colonn3");
          $this->db->where("colonn3",$data);
          return $this->db->get("table")->result_array();


          //controller



          $colonn3_exsist = $this->my_model->get_colonn3($data)
          if($colonn3_exsist>0)
          echo"ok";






          share|improve this answer



























            0












            0








            0







            try this:



            //model



            function get_colonn3($data){
            $this->db->select("colonn3");
            $this->db->where("colonn3",$data);
            return $this->db->get("table")->result_array();


            //controller



            $colonn3_exsist = $this->my_model->get_colonn3($data)
            if($colonn3_exsist>0)
            echo"ok";






            share|improve this answer













            try this:



            //model



            function get_colonn3($data){
            $this->db->select("colonn3");
            $this->db->where("colonn3",$data);
            return $this->db->get("table")->result_array();


            //controller



            $colonn3_exsist = $this->my_model->get_colonn3($data)
            if($colonn3_exsist>0)
            echo"ok";







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 27 at 4:43









            PHP GeekPHP Geek

            2,0001 gold badge8 silver badges20 bronze badges




            2,0001 gold badge8 silver badges20 bronze badges
























                0














                You are passing the value to WHERE in a wrong way. You have to pass the values in an array without passing the table name.



                You have to pass the array in WHERE clause like this if you have more than one parameter to compare from Database:



                function get_colonn3($para1,$para2)
                $this->db->select("table.colonn3");
                $this->db->where(['columnname1' => $para1, 'columnname2' => $para2]);
                return $this->db->get("table.colonn3")->result_array();



                If you have only one parameter to compare then you can use this:



                function get_colonn3($para1)
                $this->db->select("table.colonn3");
                $this->db->where('columnname1',$para1);
                return $this->db->get("table.colonn3")->result_array();






                share|improve this answer





























                  0














                  You are passing the value to WHERE in a wrong way. You have to pass the values in an array without passing the table name.



                  You have to pass the array in WHERE clause like this if you have more than one parameter to compare from Database:



                  function get_colonn3($para1,$para2)
                  $this->db->select("table.colonn3");
                  $this->db->where(['columnname1' => $para1, 'columnname2' => $para2]);
                  return $this->db->get("table.colonn3")->result_array();



                  If you have only one parameter to compare then you can use this:



                  function get_colonn3($para1)
                  $this->db->select("table.colonn3");
                  $this->db->where('columnname1',$para1);
                  return $this->db->get("table.colonn3")->result_array();






                  share|improve this answer



























                    0












                    0








                    0







                    You are passing the value to WHERE in a wrong way. You have to pass the values in an array without passing the table name.



                    You have to pass the array in WHERE clause like this if you have more than one parameter to compare from Database:



                    function get_colonn3($para1,$para2)
                    $this->db->select("table.colonn3");
                    $this->db->where(['columnname1' => $para1, 'columnname2' => $para2]);
                    return $this->db->get("table.colonn3")->result_array();



                    If you have only one parameter to compare then you can use this:



                    function get_colonn3($para1)
                    $this->db->select("table.colonn3");
                    $this->db->where('columnname1',$para1);
                    return $this->db->get("table.colonn3")->result_array();






                    share|improve this answer













                    You are passing the value to WHERE in a wrong way. You have to pass the values in an array without passing the table name.



                    You have to pass the array in WHERE clause like this if you have more than one parameter to compare from Database:



                    function get_colonn3($para1,$para2)
                    $this->db->select("table.colonn3");
                    $this->db->where(['columnname1' => $para1, 'columnname2' => $para2]);
                    return $this->db->get("table.colonn3")->result_array();



                    If you have only one parameter to compare then you can use this:



                    function get_colonn3($para1)
                    $this->db->select("table.colonn3");
                    $this->db->where('columnname1',$para1);
                    return $this->db->get("table.colonn3")->result_array();







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 27 at 5:20









                    Saad TanvirSaad Tanvir

                    13 bronze badges




                    13 bronze badges
























                        0














                        Model



                         function get_colonn3($data)
                        return $this->db->select("table.colonn3 as col3")->from('table')->where(['table.colonn3' => $data])->get()->row()->col3;



                        Controller



                        $colonn3 = $this->my_model->get_colonn3($data)

                        if(!empty($colonn3)):
                        echo "ok";
                        endif;





                        share|improve this answer





























                          0














                          Model



                           function get_colonn3($data)
                          return $this->db->select("table.colonn3 as col3")->from('table')->where(['table.colonn3' => $data])->get()->row()->col3;



                          Controller



                          $colonn3 = $this->my_model->get_colonn3($data)

                          if(!empty($colonn3)):
                          echo "ok";
                          endif;





                          share|improve this answer



























                            0












                            0








                            0







                            Model



                             function get_colonn3($data)
                            return $this->db->select("table.colonn3 as col3")->from('table')->where(['table.colonn3' => $data])->get()->row()->col3;



                            Controller



                            $colonn3 = $this->my_model->get_colonn3($data)

                            if(!empty($colonn3)):
                            echo "ok";
                            endif;





                            share|improve this answer













                            Model



                             function get_colonn3($data)
                            return $this->db->select("table.colonn3 as col3")->from('table')->where(['table.colonn3' => $data])->get()->row()->col3;



                            Controller



                            $colonn3 = $this->my_model->get_colonn3($data)

                            if(!empty($colonn3)):
                            echo "ok";
                            endif;






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Mar 27 at 5:30









                            Prabu samvelPrabu samvel

                            1,1243 silver badges14 bronze badges




                            1,1243 silver badges14 bronze badges






























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55357523%2fquery-in-php-on-codeigniter%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                                Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                                Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript