PHP code example of hershel-theodore-layton / sql-queryf

1. Go to this page and download the library: Download hershel-theodore-layton/sql-queryf library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hershel-theodore-layton / sql-queryf example snippets

HACK
type QueryType = SQL\Query;

function queryf(
  HH\FormatString<SQL\QueryFormat> $format,
  mixed ...$args
)[defaults]: QueryType {
  return \HH\FIXME\UNSAFE_CAST<dynamic, dynamic>(SQL\Query::class)
    |> new $$($format, $args);
}

function query_to_native(QueryType $query)[]: SQL\Query {
  return $query;
}
HACK
type QueryType = SqlQueryf\HipHopLibSqlQueryPack;

function queryf(
  HH\FormatString<ToString\Sql> $format,
  mixed ...$args
)[]: SqlQueryf\HipHopLibSqlQueryPack {
  return SqlQueryf\HipHopLibSqlQueryPack::createWithoutTypechecking_UNSAFE(
    $format as string,
    vec($args),
  );
}

function query_to_native(
  SqlQueryf\HipHopLibSqlQueryPack $query,
)[defaults]: SQL\Query {
  $args = vec[];

  foreach ($pack->getArguments() as $a) {
    if ($a is SqlQueryf\HipHopLibSqlQueryPack) {
      $args[] = query_to_native($a);
    } else {
      $args[] = $a;
    }
  }

  return \HH\FIXME\UNSAFE_CAST<dynamic, dynamic>(SQL\Query::class)
    |> new $$($pack->getFormat(), $args);
}