People, when you will start to learn that such approach is a mess?
First, use ' ' instead of " " and format your SQL better and you woun't have
any problems:

<?php
define ('STATUS_ACTIVE', 1);
define ('NUM_PER_PAGE', 25);
// I beleve here is a lot of code
//  ...
// ....
$q = 'SELECT
    ID, Name
FROM Projects
WHERE StatusID = '.STATUS_ACTIVE.'
LIMIT '.NUM_PER_PAGE.', '.$offset;
$res = mysql_query ($q);
?>
a). It's more readable without syntax highlighting
b). It's just faster.
c). It's a good style.
d). I think if that is easy to do, it would be implemented a long time ago.


2008/10/29 Josh <[EMAIL PROTECTED]>

> Hello,
>
> What is the chance of support for constants in double-quoted strings
> in PHP 5.3 or PHP 6.0?
>
> This is something I have wanted for some time now.
>
> Use cases:
> Writing an SQL query that makes use of a status field
> <?php
> define ('STATUS_ACTIVE', 1);
> define ('NUM_PER_PAGE', 25);
> $q = "SELECT ID, Name FROM Projects WHERE StatusID = " . STATUS_ACTIVE
> . " LIMIT " . NUM_PER_PAGE . " OFFSET {$offset}";
> $res = mysql_query ($q);
> ?>
>
> Syntax suggestions:
> Constants would need to be contained within curly braces. e.g.
> "SELECT ID, Name FROM Projects WHERE StatusID = {STATUS_ACTIVE} LIMIT
> {NUM_PER_PAGE} OFFSET {$offset}"
> The syntax would therefore be:
> '{', one or more of [-_a-zA-Z0-9], '}'
> If not constant is found, the string should be inserted directly.
> If that causes too much parsing issues, perhaps a symbol should be
> placed before or after the opening brace. e.g.
> "SELECT ID, Name FROM Projects WHERE StatusID = {#STATUS_ACTIVE} LIMIT
> #{NUM_PER_PAGE} OFFSET {$offset}"
>
> Regards,
> Josh
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to