db_binds.anubis 2.01 KB
/*
 * Created by PyramIDE.
 * User: フランスのトトロ aka (David RENÉ) 
 * Date: 17/03/2017
 * Time: 00:14
 * © David RENÉ
 */

transmit xlib/database/types/db_id.anubis
transmit xlib/database/types/db_date.anubis
transmit xlib/database/types/db_time.anubis
transmit xlib/database/types/db_datetime.anubis
transmit xlib/database/db_types.anubis

 extended version of bind for SQLite3.

public define SQLite3Bind
  bind_DB_id_or_NULL
  (
    String  _name,
    DB_id   _value
  )=
  if _value is
  {
    none          then bind_NULL(_name)
    db_id(value)  then bind_Int(_name, value)
  }
.

public define SQLite3Bind
  bind_DB_id_or_NULL
  (
    String        _name,
    Maybe(DB_id)  mb_value
  )=
  if mb_value is
  {
    failure      then bind_NULL(_name)
    success(id)  then bind_DB_id_or_NULL(_name, id)
  }
.
    
public define SQLite3Bind
  bind_Int_or_NULL
  (
    String     name,
    Maybe(Int) mb_value
  )=
  if mb_value is 
  {
    failure         then  bind_NULL(name),
    success(value)  then  bind_Int(name, value)
  }
.

public define SQLite3Bind
  bind_String_or_NULL
  (
    String  name,
    String  value
  )=
  if value = "{NULL}" then
    bind_NULL(name)
  else
    bind_String(name, value).
  
public define SQLite3Bind
  bind_Datetime
  (
    String      name,
    DB_datetime dt
  )=
  if dt.datetime = "" | dt.datetime = "{NULL}" then
    bind_NULL(name)
  else
    bind_String(name, dt.datetime).

public define SQLite3Bind
  bind_Date
  (
    String  name,
    DB_date d
  )=
  if d.date = "" | d.date = "{NULL}" then
    bind_NULL(name)
  else
    bind_String(name, d.date).
  
public define SQLite3Bind
  bind_Time
  (
    String  name,
    DB_time d
  )=
  if d.time = "" | d.time = "{NULL}" then
    bind_NULL(name)
  else  
    bind_String(name, d.time).
  
public define SQLite3Bind
  bind_Bool
  (
    String  name,
    Bool    value
  )=
  bind_Int(name, to_DBInt(value)).

public define SQLite3Bind
  bind_BLOB
  (
    String    name,
    $V        value
  )=
  bind_ByteArray(name, serialize(value)).