yii 利用query 對資料庫的操作

2021-06-04 02:28:55 字數 564 閱讀 1429

$sql="select * from `express_template` where `ec_id`=$ec_id";

$command = $connection->createcommand($sql);

$result = $command->queryall();

$imgaddress = yiibase::getpathofalias('webroot').'/static/ship_tpl_bg_imgs/'.$result[0]['bg'];

@unlink($imgaddress);

上面的操作是 將表中的字段給讀出來,然後執行刪除檔案的操作。

$sql="update `express_template` set `bg`='".$name."' where`ec_id`=$ec_id";

$command = $connection->createcommand($sql);

$command->execute();

執行更新資料表中乙個欄位的功能,$command->execute() 返回的結果為1或者0

yii 利用query 對資料庫的操作

sql select from express template where ec id ec id command connection createcommand sql result command queryall imgaddress yiibase getpathofalias webr...

通過pdo的query 方法對資料庫進行操作

phpheader content type text html charset utf 8 例項化pdo物件 pdo new pdo mysql host 127.0.0.1 port 3306 dbname test root 888888 通過query函式執行sql命令 pdo query ...

利用jsp mysql 對資料庫進行訪問

connection conn null statement stmt 載入資料庫驅動類 class.forname com.mysql.jdbc.driver newinstance 資料庫連線url string url jdbc mysql 我本地資料庫的名稱叫做ysp 資料庫使用者名稱和密碼...