Sim Posted April 17, 2020 Share Posted April 17, 2020 I would like to see this added into the next feature of GL to help with the ease of not having to bind every methodData. I'd like to see some sort of function, maybe bindMethodData($exclude) that will automatically bind all the methodData. This would save a ton of time. bindParam(blah 1, methodData1) BindParam(blah2, methodData2) BindParam(blah3, methodData3). BindParam(blah4, methodData4) Ext BindMethodData will automatically do all that above. $dontBind[] = 1' $dontBind[] = 2 bindMethodData('$dontBind). Will bind the 3 and 4 but not the ones to exclude. Fairly simple to do, and surprised it hasn't been built in yet. Quote Link to comment Share on other sites More sharing options...
Dayo Posted April 17, 2020 Share Posted April 17, 2020 Sorry i don't understand what you mean 😕 if you want to allow anything in methodData you can add this public $allowedMethods = "*"; 1 Quote Link to comment Share on other sites More sharing options...
Sim Posted April 17, 2020 Author Share Posted April 17, 2020 $insert = $this->db->prepare(" INSERT INTO skills (SK_name, SK_default, SK_max, SK_canUpdate, SK_isHidden) VALUES (:name, :defaultValue, :maxValue, :canUpdate, :isHidden);"); $insert->bindParam(":name", $this->methodData->name); $insert->bindParam(":maxValue", $this->methodData->maxValue); $insert->bindParam(":canUpdate", $this->methodData->canUpdate); $insert->bindParam(":isHidden", $this->methodData->isHidden); $insert->bindParam(":defaultValue", $this->methodData->defaultValue); $insert->execute(); So we usually have to do this for adding form data to the database. $insert = $this->db->prepare(" INSERT INTO skills (SK_name, SK_default, SK_max, SK_canUpdate, SK_isHidden) VALUES (:name, :defaultValue, :maxValue, :canUpdate, :isHidden);"); $insert->bindMethodData(); $insert->execute(); //first post, exclude excludes which methodDatas to not bind from thrle ye methodDatas //$insert->bindMethodData($exclude); Now the 2nd way is much more convenient. These is especially helpful in the admin panel area where people are adding and edited data all the time. AS YOU can see the 2nd way would b much faster and just more convenient in general Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted April 17, 2020 Share Posted April 17, 2020 In your execute method you can pass an array of key => values to bind instead of using bindParam one at a time Quote Link to comment Share on other sites More sharing options...
Sim Posted April 17, 2020 Author Share Posted April 17, 2020 (edited) You still have to type all the keys and values when the method could automatically do it. @KyleMassacre Edited April 17, 2020 by Sim Quote Link to comment Share on other sites More sharing options...
Dayo Posted April 17, 2020 Share Posted April 17, 2020 $this->db->insert("qyery", (array) $this->methodData); @sim Quote Link to comment Share on other sites More sharing options...
Sim Posted April 17, 2020 Author Share Posted April 17, 2020 qwery? Seriously? This some hidden Easter eggs? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.