{"__v":1,"_id":"5544d76bd8833c0d00582836","category":{"__v":1,"_id":"5544d76ad8833c0d00582802","pages":["5544d76bd8833c0d00582832","5544d76bd8833c0d00582833","5544d76bd8833c0d00582834","5544d76bd8833c0d00582835","5544d76bd8833c0d00582836","5544d76bd8833c0d00582837","5544d76bd8833c0d00582838","5544d76bd8833c0d00582839","5544d76bd8833c0d0058283a","5544d76bd8833c0d0058283b","5544d76bd8833c0d0058283c","5544d76bd8833c0d0058283d"],"project":"55227389b4a0de0d00de7e28","version":"5544d76ad8833c0d00582801","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-06T11:52:42.014Z","from_sync":false,"order":0,"slug":"_","title":"コア"},"project":"55227389b4a0de0d00de7e28","user":"551952063414b40d00e470cb","version":{"__v":1,"_id":"5544d76ad8833c0d00582801","forked_from":"55227389b4a0de0d00de7e2b","project":"55227389b4a0de0d00de7e28","createdAt":"2015-05-02T13:55:54.059Z","releaseDate":"2015-05-02T13:55:54.059Z","categories":["5544d76ad8833c0d00582802","5544d76ad8833c0d00582803","5544d76ad8833c0d00582804","5544d76ad8833c0d00582805","5544d76ad8833c0d00582806"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"4.0.0","version":"4.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-04-06T12:02:39.362Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"?u\"\n}\n[/block]\nデータを更新するための構造持つ配列を格納します:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$data = array (\\n    'payment_id' => 5\\n    );\\n$order_id = 3;\\n \\ndb_query('UPDATE ?:orders SET ?u WHERE order_id = ?i', $data, $order_id);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n上記PHPコードは以下のSQLとなります。\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"UPDATE cscart_orders SET payment_id = '5' WHERE order_id = 3;\",\n      \"language\": \"mysql\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"?e\"\n}\n[/block]\nデータを挿入するための構造持つ配列を格納します:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$data = array (\\n    'payment_id' => 5,\\n    'order_id' => 3\\n);\\n \\ndb_query('INSERT INTO ?:orders ?e', $data);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n上記PHPコードは以下のSQLとなります。\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"INSERT INTO cscart_orders (payment_id, order_id) VALUES ('5', '3');\",\n      \"language\": \"mysql\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"?i\"\n}\n[/block]\n文字列や数値を受け取り、整数に変換します\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$order_id = 4;\\ndb_query('SELECT * FROM ?:orders WHERE order_id = ?i', $order_id);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n上記PHPコードは以下のSQLとなります。\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SELECT * FROM cscart_orders WHERE order_id = 4;\",\n      \"language\": \"mysql\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"?s\"\n}\n[/block]\n文字列や数値を(スラッシュを追加して)文字列に変換します\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$order_id = 'adasd';\\ndb_query('SELECT * FROM ?:orders WHERE order_id = ?s', $order_id);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n上記PHPコードは以下のSQLとなります。\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SELECT * FROM cscart_orders WHERE order_id = 'foo';\",\n      \"language\": \"mysql\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"?l\"\n}\n[/block]\n受け取ったデータをLIKEオペレーターに置換するために文字列に変換します(ダブルバックスラッシュに変換されスラッシュが追加されます)\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$piece = '%black\\\\white%';\\ndb_query('SELECT * FROM ?:product_descriptions WHERE product LIKE ?l', $piece);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n上記PHPコードは以下のSQLとなります。\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SELECT * FROM cscart_product_descriptions WHERE product LIKE '%black\\\\\\\\\\\\\\\\white%';\",\n      \"language\": \"mysql\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"?d\"\n}\n[/block]\nデータをデシマル(分数)に変換する\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$order_id = '123.345345';\\ndb_query('SELECT * FROM ?:orders WHERE order_id = ?d', $order_id);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n上記PHPコードは以下のSQLとなります。\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SELECT * FROM cscart_orders WHERE order_id = '123.35';\",\n      \"language\": \"mysql\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"?a\"\n}\n[/block]\nprepares data to be used in the structure IN () as a set of strings, receives a string, number, array:\n文字列や数値、配列をIN ()で使えるデータに変換します\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$order_id = '123';\\ndb_query('SELECT * FROM ?:orders WHERE order_id IN (?a)', $order_id);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n上記PHPコードは以下のSQLとなります。\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SELECT * FROM cscart_orders WHERE order_id IN ('123');\",\n      \"language\": \"mysql\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"?n\"\n}\n[/block]\n??????\n文字列や数値、配列をIN ()で使えるデータに変換します\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$order_id = '123.45';\\ndb_query('SELECT * FROM ?:orders WHERE order_id IN (?n)', $order_id);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"?p\"\n}\n[/block]\n準備された値の挿入:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$order_id = 'order_id = 4';\\ndb_query('SELECT * FROM ?:orders WHERE ?p', $order_id);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n上記PHPコードは以下のSQLとなります。\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SELECT * FROM cscart_orders WHERE order_id = 4;\",\n      \"language\": \"mysql\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"?w\"\n}\n[/block]\nWHERE句で使えるデータを格納します\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$data = array (\\n    'payment_id' => 5,\\n    'order_id' => 3\\n);\\n \\ndb_query('SELECT * FROM ?:orders WHERE ?w', $data);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n上記PHPコードは以下のSQLとなります。\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SELECT * cscart_orders WHERE payment_id = '5' AND order_id = '3';\",\n      \"language\": \"mysql\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"?f\"\n}\n[/block]\n変数の値が有効なフィールド名かチェックします\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$data = 'payment:::at:::id';\\n \\ndb_query('SELECT * FROM ?:orders WHERE ?f = 5', $data);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n上記PHPコードは以下のSQLとなります。\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SELECT * FROM cscart_orders WHERE  = 5;\",\n      \"language\": \"mysql\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"?m\"\n}\n[/block]\nマルチインサートに対応する配列を格納します。\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$data = array(\\n    array(\\n        'payment_id' => 5,\\n        'order_id' => 3\\n    ),\\n    array(\\n        'payment_id' => 5,\\n        'order_id' => 4\\n    ),\\n);\\n \\ndb_query('INSERT INTO ?:orders ?m', $data);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n上記PHPコードは以下のSQLとなります。\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"INSERT INTO cscart_orders (payment_id, order_id) VALUES ('5', '3'),('5', '4');\",\n      \"language\": \"mysql\"\n    }\n  ]\n}\n[/block]","excerpt":"CS-Cartが行うデータベースへのリクエストは、プレースホルダーを使用して生成されます。","slug":"placeholders","type":"basic","title":"プレイスホルダー"}

プレイスホルダー

CS-Cartが行うデータベースへのリクエストは、プレースホルダーを使用して生成されます。

[block:api-header] { "type": "basic", "title": "?u" } [/block] データを更新するための構造持つ配列を格納します: [block:code] { "codes": [ { "code": "<?php\n$data = array (\n 'payment_id' => 5\n );\n$order_id = 3;\n \ndb_query('UPDATE ?:orders SET ?u WHERE order_id = ?i', $data, $order_id);", "language": "php" } ] } [/block] 上記PHPコードは以下のSQLとなります。 [block:code] { "codes": [ { "code": "UPDATE cscart_orders SET payment_id = '5' WHERE order_id = 3;", "language": "mysql" } ] } [/block] [block:api-header] { "type": "basic", "title": "?e" } [/block] データを挿入するための構造持つ配列を格納します: [block:code] { "codes": [ { "code": "<?php\n$data = array (\n 'payment_id' => 5,\n 'order_id' => 3\n);\n \ndb_query('INSERT INTO ?:orders ?e', $data);", "language": "php" } ] } [/block] 上記PHPコードは以下のSQLとなります。 [block:code] { "codes": [ { "code": "INSERT INTO cscart_orders (payment_id, order_id) VALUES ('5', '3');", "language": "mysql" } ] } [/block] [block:api-header] { "type": "basic", "title": "?i" } [/block] 文字列や数値を受け取り、整数に変換します [block:code] { "codes": [ { "code": "<?php\n$order_id = 4;\ndb_query('SELECT * FROM ?:orders WHERE order_id = ?i', $order_id);", "language": "php" } ] } [/block] 上記PHPコードは以下のSQLとなります。 [block:code] { "codes": [ { "code": "SELECT * FROM cscart_orders WHERE order_id = 4;", "language": "mysql" } ] } [/block] [block:api-header] { "type": "basic", "title": "?s" } [/block] 文字列や数値を(スラッシュを追加して)文字列に変換します [block:code] { "codes": [ { "code": "<?php\n$order_id = 'adasd';\ndb_query('SELECT * FROM ?:orders WHERE order_id = ?s', $order_id);", "language": "php" } ] } [/block] 上記PHPコードは以下のSQLとなります。 [block:code] { "codes": [ { "code": "SELECT * FROM cscart_orders WHERE order_id = 'foo';", "language": "mysql" } ] } [/block] [block:api-header] { "type": "basic", "title": "?l" } [/block] 受け取ったデータをLIKEオペレーターに置換するために文字列に変換します(ダブルバックスラッシュに変換されスラッシュが追加されます) [block:code] { "codes": [ { "code": "<?php\n$piece = '%black\\white%';\ndb_query('SELECT * FROM ?:product_descriptions WHERE product LIKE ?l', $piece);", "language": "php" } ] } [/block] 上記PHPコードは以下のSQLとなります。 [block:code] { "codes": [ { "code": "SELECT * FROM cscart_product_descriptions WHERE product LIKE '%black\\\\\\\\white%';", "language": "mysql" } ] } [/block] [block:api-header] { "type": "basic", "title": "?d" } [/block] データをデシマル(分数)に変換する [block:code] { "codes": [ { "code": "<?php\n$order_id = '123.345345';\ndb_query('SELECT * FROM ?:orders WHERE order_id = ?d', $order_id);", "language": "php" } ] } [/block] 上記PHPコードは以下のSQLとなります。 [block:code] { "codes": [ { "code": "SELECT * FROM cscart_orders WHERE order_id = '123.35';", "language": "mysql" } ] } [/block] [block:api-header] { "type": "basic", "title": "?a" } [/block] prepares data to be used in the structure IN () as a set of strings, receives a string, number, array: 文字列や数値、配列をIN ()で使えるデータに変換します [block:code] { "codes": [ { "code": "<?php\n$order_id = '123';\ndb_query('SELECT * FROM ?:orders WHERE order_id IN (?a)', $order_id);", "language": "php" } ] } [/block] 上記PHPコードは以下のSQLとなります。 [block:code] { "codes": [ { "code": "SELECT * FROM cscart_orders WHERE order_id IN ('123');", "language": "mysql" } ] } [/block] [block:api-header] { "type": "basic", "title": "?n" } [/block] ?????? 文字列や数値、配列をIN ()で使えるデータに変換します [block:code] { "codes": [ { "code": "<?php\n$order_id = '123.45';\ndb_query('SELECT * FROM ?:orders WHERE order_id IN (?n)', $order_id);", "language": "php" } ] } [/block] [block:api-header] { "type": "basic", "title": "?p" } [/block] 準備された値の挿入: [block:code] { "codes": [ { "code": "<?php\n$order_id = 'order_id = 4';\ndb_query('SELECT * FROM ?:orders WHERE ?p', $order_id);", "language": "php" } ] } [/block] 上記PHPコードは以下のSQLとなります。 [block:code] { "codes": [ { "code": "SELECT * FROM cscart_orders WHERE order_id = 4;", "language": "mysql" } ] } [/block] [block:api-header] { "type": "basic", "title": "?w" } [/block] WHERE句で使えるデータを格納します [block:code] { "codes": [ { "code": "<?php\n$data = array (\n 'payment_id' => 5,\n 'order_id' => 3\n);\n \ndb_query('SELECT * FROM ?:orders WHERE ?w', $data);", "language": "php" } ] } [/block] 上記PHPコードは以下のSQLとなります。 [block:code] { "codes": [ { "code": "SELECT * cscart_orders WHERE payment_id = '5' AND order_id = '3';", "language": "mysql" } ] } [/block] [block:api-header] { "type": "basic", "title": "?f" } [/block] 変数の値が有効なフィールド名かチェックします [block:code] { "codes": [ { "code": "<?php\n$data = 'payment@id';\n \ndb_query('SELECT * FROM ?:orders WHERE ?f = 5', $data);", "language": "php" } ] } [/block] 上記PHPコードは以下のSQLとなります。 [block:code] { "codes": [ { "code": "SELECT * FROM cscart_orders WHERE = 5;", "language": "mysql" } ] } [/block] [block:api-header] { "type": "basic", "title": "?m" } [/block] マルチインサートに対応する配列を格納します。 [block:code] { "codes": [ { "code": "<?php\n$data = array(\n array(\n 'payment_id' => 5,\n 'order_id' => 3\n ),\n array(\n 'payment_id' => 5,\n 'order_id' => 4\n ),\n);\n \ndb_query('INSERT INTO ?:orders ?m', $data);", "language": "php" } ] } [/block] 上記PHPコードは以下のSQLとなります。 [block:code] { "codes": [ { "code": "INSERT INTO cscart_orders (payment_id, order_id) VALUES ('5', '3'),('5', '4');", "language": "mysql" } ] } [/block]