简体   繁体   中英

single quotes inside double quotes php

I am updating a script that I am using from using hardcoded date to using constants from a config file. It was working okay until I got to the following bit.

original:

function getDestroyedRelationships($relation){
$owner_user_id = $_REQUEST['owner_user_id'];
$tableName = "";
if($relation=="friends"){
    $tableName = "yst_twitter_following_relationships";
}else if($relation=="followers"){
    $tableName = "yst_twitter_follower_relationships";
}else{
    return false;
}
$twitters = NULL;
$stmt = ulPdoDb::Prepare('log', 'SELECT your_id FROM '.$tableName.' WHERE my_id=? AND updated_on<(SELECT MAX(updated_on) FROM '.$tableName.' WHERE my_id=?)');
if (!ulPdoDb::BindExec(
    $stmt,
    array(      // output
        &$twitters, 'lob'
    ),
    array(      // input
        &$owner_user_id, 'int',
        &$owner_user_id, 'int'
    )
))
{
    ul_db_fail();
    return false;
}

if ($twitters = $stmt->fetchAll(PDO::FETCH_COLUMN))
{
    return $twitters;
}
else
{
    //echo "Nothing";
}
return $twitters;
}

As you can see in the above the $tablename has the table prefix 'yst' defined. I would like to change the 'yst' to read:

'.TABLE_PREFIX'

However when doing this I get the following error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''.TABLE_PREFIX.'_twitter_following_relationships (my_id, your_id, created_on, up'

I suspect this is to do with the single quote being next to the double quotes?

Any advice? Thanks

假设TABLE_PREFIX是您在某处定义的常量,请执行以下操作:

    $tableName = TABLE_PREFIX.'_twitter_following_relationships';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM