List:General Discussion« Previous MessageNext Message »
From:AndrewJames Date:September 4 2009 11:34am
Subject:Re: AW: Re: a better way, code technique?
View as plain text  
hahah thank-you, love the responses here. you guys are awesome..

ps, where does the %s come from?

--------------------------------------------------
From: <Majk.Skoric@stripped>
Sent: Friday, September 04, 2009 9:11 PM
To: <per@stripped>; <mysql@stripped>
Subject: AW:  Re: a better way, code technique?

> -----Ursprüngliche Nachricht-----
> Von: Per Jessen [mailto:per@stripped]
> Gesendet: Freitag, 4. September 2009 13:05
> An: mysql@stripped
> Betreff: Re: a better way, code technique?
>
> AndrewJames wrote:
>
>>> is there a better way (hopefully simpler) to code this?
>>>
>>> i want to get the user id of the logged in user to use in my next
>>> statement.
>>>
>>> $q1 = sprintf("SELECT uid FROM users WHERE
>>> users.username='$username'");
>
>>The only "improvement" I can see is:
>>
>>$q1 = sprintf("SELECT uid FROM users WHERE users.username='%s'",
>>$username);
>
> sprintf only adds overhead to this. There is no need to use it here.
>
> You can just use $q = "SELECT ...";
> Or if you wanna have it more readable use heredoc style
>
> $q = <<<EOSQL
> SELECT
> uid
> FROM
> users
> WHERE
> username = '{$username}'
> EOSQL;
>
> But thats a bit off topic ;)
>
> Majk
> 
Thread
a better way, code technique?AndrewJames4 Sep
  • AW: a better way, code technique?Majk.Skoric4 Sep
    • AW: a better way, code technique?Majk.Skoric4 Sep
  • Re: a better way, code technique?Per Jessen4 Sep
    • AW: Re: a better way, code technique?Majk.Skoric4 Sep
      • Re: AW: Re: a better way, code technique?AndrewJames4 Sep
        • AW: AW: Re: a better way, code technique?Majk.Skoric4 Sep
  • Re: a better way, code technique?Brent Baisley4 Sep
    • RE: a better way, code technique?Gavin Towey4 Sep
    • RE: a better way, code technique?Daevid Vincent4 Sep