HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Search
-
Re: How do Increment value in mysql update query when the column is a variable?? can it be done?
BINGO! I got both working techniques thanks much. @businessdad and @x00 :) @businessdad - thanks for the proof of concept and the ultimate answer. I was beginning to wonder. I'd probably be at this for a long long time ..... i was trying AS and Set @Tempvar and strings, thinking it couldn't be done with the set () syntax.… -
Re: How do Increment value in mysql update query when the column is a variable?? can it be done?
The benefit of the query builder is you can break it up. $SQLStatement = Gdn::SQL();$SQLStatement->Update('Table');if(condition){ $SQLStatement->Set('MyColumn','MyColumn + 1',FALSE)}else{ $SQLStatement->Set('MyColumn1','MyColumn1 + 1',FALSE)}$SQLStatement->Where(array('MyColID'=>$MyID))->Put(); alternatively you an supply… -
Re: How do Increment value in mysql update query when the column is a variable?? can it be done?
-
Re: How do Increment value in mysql update query when the column is a variable?? can it be done?
Ok, I think I got it now. I think you can either do like this: $SQL = " UPDATE GDN_SomeTable SET $ColumnVar= $ColumnVar + 1 WHERE MyID = $BlahID"; // Obviously, $BlahID should be sanitised before usedGdn::Database()->Query($SQL); Or, as @x00 wrote, like this: ->Set($ColumnVar, "$ColumnVar + 1", FALSE) Note the double… -
Re: How do Increment value in mysql update query when the column is a variable?? can it be done?
-
Re: How do Increment value in mysql update query when the column is a variable?? can it be done?
Actually, I'm not sure I understood the question. A while back I was doing something that I can't reall what and where :). But lets say you want to update certain columns in a table. Each column update based on whether something meets a certain criteria. All in a "single sql" update using vanilla lingo. If $a = "Yes"… -
How do Increment value in mysql update query when the column is a variable?? can it be done?
I can do this $BlahID = "3"; $MyColumn = "ColumnA"; so the value in MyColumn is e.g. "5" it read the 5 and increments the number in the column, so it is now 6. Gdn::SQL() ->Update('MyTable') ->Set(array($MyColumn => ColumnA + 1)) ->Where(array('MyID'=>$BlahID)) ->Put(); However, how does one do this when it is a variable.… -
Re: How do Increment value in mysql update query when the column is a variable?? can it be done?
-
Re: How do Increment value in mysql update query when the column is a variable?? can it be done?
-
Re: How do Increment value in mysql update query when the column is a variable?? can it be done?
10 results