简体   繁体   中英

How to select mssql schema by using php queries?

I had a issue when tried to restore prod database into a dev database because it is divided by schema. Is it possible to select schema using PHP code?

I don't think PHP has a built in function to do this, but i have found a solution that worked very well for me.

function setSchema($query, $schema) {
    $query = str_ireplace('from ', "from {$schema}.", $query);
    $query = str_ireplace('update ', "update {$schema}.", $query);
    $query = str_ireplace('join ', "join {$schema}.", $query);
    $query = str_ireplace('into ', "into {$schema}.", $query);
    return $query;
}

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