[PHP x SQLite3]PHPでSQLite3 #6データ削除(DELETE)
PHPでSQLite3 #6データ削除(DELETE)
$sql="DELETE FROM $tableName WHERE id = $id"; $result=$db->query($sql);
PHPでSQLite3 #6データ削除(DELETE)
$sql="DELETE FROM $tableName WHERE id = $id"; $result=$db->query($sql);
PHPでSQLite3 #5データ更新(UPDATE)
$sql="SELECT id,cnt FROM $tableName WHERE id='{$id}'"; $result=$db->query($sql); $row = $result->fetchArray(); $id=$row['id']; $cnt=$row['cnt']+1; $sql="UPDATE $tableName SET cnt = $cnt WHERE id = $id"; $result=$db->query($sql);
PHPでSQLite3 #4データ挿入(INSERT)
$sql="INSERT INTO $tableName(name,title,cnt) VALUES('{$name}','{$title}',1)"; $result=$db->query($sql);
PHPでSQLite3 #3データ取得(SELECT)
$tableName="access"; $sql="SELECT id,name,cnt FROM $tableName WHERE name='{$name}' ORDER BY cnt ASC"; $result=$db->query($sql); $tmp=[]; while ($row = $result->fetchArray(SQLITE3_ASSOC)) { $tmp[]=$row; } echo json_encode($tmp); $db->close();
データ重複しないように取得
$sql="SELECT DISTINCT name FROM $tableName"; $result=$db->query($sql); if($result===FALSE){ $db->close(); echo $message; exit; } $tmp=[]; while ($row = $result->fetchArray(SQLITE3_ASSOC)) { $value=$row['name']; $tmp[]=$value; } echo json_encode($tmp);
PHPでSQLite3 #2テーブル作成
$tableName="access"; $sql="create table if not exists $tableName (id INTEGER PRIMARY KEY AUTOINCREMENT, name varchar(6), title text, cnt int)"; $result=$db->query($sql); if ($result===FALSE) { $db->close(); echo $message; exit; } $db->close();
substr
$str='abcd'; echo substr($str,1,2);
結果
bc
$str='abcd'; echo substr($str,0,-1);
結果
abc
$str='abcd'; echo substr($str,-1);
結果
d
PHPでSQLite3 #1接続
try { $db = new SQLite3('test.db'); } catch (Exception $e) { echo $message; exit; }
UINavigationControllerの戻るボタンの文字を変える
self.navigationController pushViewControllerの直前に
UIBarButtonItem *backButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"戻る" style:UIBarButtonItemStyleBordered target:nil action:nil]; self.navigationItem.backBarButtonItem=backButtonItem;
UINavigationControllerのタイトルを設定
これではだめ
self.navigationController.title=@"TheTitle";
こうする
self.navigationItem.title=@"TheTitle";
UIColorからRGBA値を取得
float r,g,b,alpha; [backgroundColor getRed:&r green:&g blue:&b alpha:&alpha];
値は0.0〜1.0