[PHP]idiorm #9 create
$record = ORM::for_table('posts')->create(); $record->number = $post['number']; $record->name = $post['name']; $record->save();
$record = ORM::for_table('posts')->create(); $record->number = $post['number']; $record->name = $post['name']; $record->save();
/** * initWithScrollY * * @static */ static initWithScrollY(){ let scrollY = localStorage.getItem('scrollKey'); if(!scrollY){ return; } localStorage.removeItem('scrollKey'); scrollY = Number(scrollY); window.scrollTo(0, scrollY); } /** * ローカルストレージ取得 * * @static * @param {String} key * @param {Boolean} remove * @returns {*} */ static getLS(key,remove){ const value = localStorage.getItem(key); if(remove){ localStorage.removeItem(key); } return value; } /** * スクロール位置を保存しつつリロード * * @static * @param {*} delay */ static reloadWithScrollY(delay){ if(delay){ setTimeout(()=>{ Utils.reloadWithScrollY(); },delay); }else{ localStorage.setItem('scrollKey',window.scrollY); location.reload(); } } /** * ローカルストレージ保存 * * @static */ static setLS(key,value){ localStorage.setItem(key,value); } /** * スクロール位置を保存 * * @static */ static setScrollYToLS(){ localStorage.setItem('scrollKey',window.scrollY); }
const { banner_status } = useSettings();
Checkout UI Extensionのshopify.extension.toml
[[extensions.settings.fields]] key = "banner_status" type = "single_line_text_field" name = "バナーの状態" [[extensions.settings.fields.validations]] name = "choices" value = '["info", "success","warning","critical"]'
let j,productId; const cartLines = useCartLines(); const appMetafields = useAppMetafields(); if(appMetafields.length){ cartLines.forEach((cartLine,i)=>{ productId = cartLine.merchandise.product.id.split("/").pop(); for(j=0;j<appMetafields.length;j++){ if(appMetafields[j].target.id === productId){ if(appMetafields[j].metafield.key === "metafieldKey" && appMetafields[j].metafield.value === "metafieldValue"){ //処理 } break; } } }); }
1
const tmp = {name:"abc"}; console.log(tmp.address?.length);
undefined
2
const tmp = {name:"abc"}; console.log(tmp.address?.length+tmp.city?.length);
NaN
3
const tmp = {name:"abc"}; console.log(tmp.address?.length+tmp.city?.length > 4);
false
4
const tmp = {name:"abc"}; console.log(tmp.address?.length+tmp.city?.length == 0);
false
5
const tmp = {name:""}; console.log(tmp.name?.length+tmp.city?.length <= 1);
false
6
const tmp = {name:""}; console.log(tmp.name?.length <= 1);
true
ivはDBに保存しているが16進数文字列でファイルに記述してもよい
SET block_encryption_mode = 'aes-256-cbc' SET @key_str = SHA2('XXXXXXX',512) SET @init_vector = RANDOM_BYTES(16) ※INSERTの時だけ実行 INSERT INTO `table_name`(shop,token,iv,created) VALUES(HEX(AES_ENCRYPT('ABC', @key_str,@init_vector)),HEX(AES_ENCRYPT('DEF', @key_str,@init_vector)),HEX(@init_vector),'2024-05-01 11:12:13') UPDATE `table_name` SET shop = HEX(AES_ENCRYPT(:shop, @key_str,@init_vector)),token = HEX(AES_ENCRYPT(:token, @key_str,@init_vector)),iv = HEX(@init_vector),modified = '2024-05-01 11:12:13' WHERE id = 5 SELECT convert(AES_DECRYPT(UNHEX(shop), @key_str,UNHEX(iv)) USING utf8) AS shop,convert(AES_DECRYPT(UNHEX(token), @key_str,UNHEX(iv)) USING utf8) AS token,created FROM `table_name` WHERE convert(AES_DECRYPT(UNHEX(shop), @key_str,UNHEX(iv)) USING utf8) = 'ABC'
triggerEvent(element, eventName){ const evt = new CustomEvent(eventName, {bubbles:true,cancelable:true}); return element.dispatchEvent(evt); }
isBrowserBack(){ const perfEntries = performance.getEntriesByType("navigation"); let result = false; perfEntries.forEach((perfEntry) => { if(perfEntry.type == 'back_forward'){ result = true; } }); return result; }