pdo = $GLOBALS['pdo']; return; } throw new \RuntimeException('Global PDO connection not initialized'); } /** * @param array{ * orderbook_flag:string, * orderbook_ts:int, * orderbook_is_token:bool, * orderbook_amount:string, * status_id:int, * user_id:int, * wallet_id:int, * token_id:int, * currency_id:?int, * chain_id:int * } $data */ public function create(array $data): array { $stmt = $this->pdo->prepare( 'INSERT INTO "orderbook" ( orderbook_flag, orderbook_ts, orderbook_is_token, orderbook_amount, status_id, user_id, wallet_id, token_id, currency_id, chain_id ) VALUES ( :orderbook_flag, :orderbook_ts, :orderbook_is_token, :orderbook_amount, :status_id, :user_id, :wallet_id, :token_id, :currency_id, :chain_id ) RETURNING orderbook_id' ); $stmt->execute([ 'orderbook_flag' => $data['orderbook_flag'], 'orderbook_ts' => $data['orderbook_ts'], 'orderbook_is_token' => $data['orderbook_is_token'], 'orderbook_amount' => $data['orderbook_amount'], 'status_id' => $data['status_id'], 'user_id' => $data['user_id'], 'wallet_id' => $data['wallet_id'], 'token_id' => $data['token_id'], 'currency_id' => $data['currency_id'], 'chain_id' => $data['chain_id'], ]); $orderbookId = (int)$stmt->fetchColumn(); return [ 'orderbook_id' => $orderbookId, 'orderbook_ts' => $data['orderbook_ts'], ]; } }