array object
w
object(stdClass)#3 (8) { ["MERCHANT_ID"]=> string(11) "MERCHANT_ID" ["MARKETPLACE_ID"]=> string(14) "MARKETPLACE_ID" ["MWSAUTH_TOKEN"]=> string(13) "MWSAUTH_TOKEN" ["AWS_ACCESS_KEY_ID"]=> string(17) "AWS_ACCESS_KEY_ID" ["AWS_SECRET_ACCESS_KEY"]=> string(21) "AWS_SECRET_ACCESS_KEY" ["countrycode"]=> string(11) "countrycode" ["startFetchDate"]=> string(14) "startFetchDate" ["is_open"]=> string(7) "is_open" } object(stdClass)#2 (8) { ["MERCHANT_ID"]=> string(6) "678678" ["MARKETPLACE_ID"]=> string(6) "678686" ["MWSAUTH_TOKEN"]=> string(6) "687768" ["AWS_ACCESS_KEY_ID"]=> string(4) "6868" ["AWS_SECRET_ACCESS_KEY"]=> string(6) "687687" ["countrycode"]=> string(2) "JP" ["startFetchDate"]=> string(10) "2017-05-31" ["is_open"]=> string(1) "0" } array(8) { ["MERCHANT_ID"]=> string(11) "MERCHANT_ID" ["MARKETPLACE_ID"]=> string(14) "MARKETPLACE_ID" ["MWSAUTH_TOKEN"]=> string(13) "MWSAUTH_TOKEN" ["AWS_ACCESS_KEY_ID"]=> string(17) "AWS_ACCESS_KEY_ID" ["AWS_SECRET_ACCESS_KEY"]=> string(21) "AWS_SECRET_ACCESS_KEY" ["countrycode"]=> string(11) "countrycode" ["startFetchDate"]=> string(14) "startFetchDate" ["is_open"]=> string(7) "is_open" } array(8) { ["MERCHANT_ID"]=> string(6) "678678" ["MARKETPLACE_ID"]=> string(6) "678686" ["MWSAUTH_TOKEN"]=> string(6) "687768" ["AWS_ACCESS_KEY_ID"]=> string(4) "6868" ["AWS_SECRET_ACCESS_KEY"]=> string(6) "687687" ["countrycode"]=> string(2) "JP" ["startFetchDate"]=> string(10) "2017-05-31" ["is_open"]=> string(1) "0" }
class extendPDO extends PDO { public function newInsert($table, $insert, $field, $inputType = 'Object') { if ($inputType = 'Object') { //bug-filter $insertStr = $this->objORArrTOStr($insert, $separator = ',', $symmetrySeparator = '"'); $insertStr = $this->delEndCharacters($insertStr); $fieldStr = $this->objORArrTOStr($field, $separator = ',', $symmetrySeparator = ''); $fieldStr = $this->delEndCharacters($fieldStr); $sql = 'INSERT INTO ' . $table . ' (' . $fieldStr . ') VALUES (' . $insertStr . ')'; $this->query($sql); } } public function newUpdate($table, $newValueSet, $fieldSet, $whereStr) { var_dump($fieldSet); var_dump($newValueSet); //for object $newValueSet = (array)$newValueSet; $fieldSet = (array)$fieldSet; var_dump($fieldSet); var_dump($newValueSet); if (count($newValueSet) == count($fieldSet)) { $sql_set = ''; foreach ($newValueSet as $key => $val) { $sql_set .= $fieldSet[$key] . '="' . $newValueSet[$key] . '",'; } $sql_set = $this->delEndCharacters($sql_set); $sql = 'UPDATE ' . $table . ' SET ' . $sql_set . $whereStr; var_dump($sql); die(); return $this->query($sql); } return false; } private function delEndCharacters($inputStr, $CharactersNum = 1) { if (strlen($inputStr) > $CharactersNum) { $res = substr($inputStr, 0, strlen($inputStr) - $CharactersNum); return $res; } return; } private function objORArrTOStr($input, $separator = ',', $symmetrySeparator = '"') { if (!empty($input)) { $str = ''; foreach ($input as $val) { $str .= $symmetrySeparator . $val . $symmetrySeparator . $separator; } return $str; } return; } public function filterRequest($request) { return $request; } public function fetchRows($sql) { $rows = array(); foreach ($this->query($sql) as $row) { $rows[] = $row; } return $rows; } } $extendPDO_db0 = new extendPDO('mysql:host=' . $CONF_DB['apiamz']['host'] . ';dbname=' . $CONF_DB['apiamz']['dbs']['apiamz0'], $CONF_DB['apiamz']['user'], $CONF_DB['apiamz']['passwd']);