EDB
[ class tree: EDB ] [ index: EDB ] [ all elements ]

Source for file EDB_MYSQLI.php

Documentation is available at EDB_MYSQLI.php

  1. <?php
  2. /**
  3.  * Project: EDB_MYSQLI :: MySQLi abstraction layer
  4.  * File:    EDB/EDB_MYSQLI.php
  5.  *
  6.  * The EDB_MYSQLI class is mysqli abstraction layer that used internally
  7.  * on EDB class.
  8.  *
  9.  * @category    Database
  10.  * @package     EDB
  11.  * @subpackage  EDB_ABSTRACT
  12.  * @author      JoungKyun.Kim <http://oops.org>
  13.  * @copyright   (c) 2018, JoungKyun.Kim
  14.  * @license     BSD License
  15.  * @version     $Id$
  16.  * @link        http://pear.oops.org/package/EDB
  17.  * @filesource
  18.  */
  19.  
  20. /**
  21.  * MySQLi engine for EDB API
  22.  *
  23.  * This class support abstracttion DB layer for MySQLi Engine
  24.  *
  25.  * @package     EDB
  26.  */
  27. Class EDB_MYSQLI extends EDB_Common {
  28.     // {{{ properties
  29.     /**#@+
  30.      * @access private
  31.      */
  32.     /**
  33.      * db handler of EDB_MYSQLI class
  34.      * @var    object 
  35.      */
  36.     private $db;
  37.     /**
  38.      * The number of query parameter
  39.      * @var    integer 
  40.      */
  41.     private $pno 0;
  42.     /**
  43.      * The number of query parameter
  44.      * @var    integer 
  45.      */
  46.     private $field array ();
  47.     /**#@-*/
  48.     // }}}
  49.  
  50.     // {{{ (object) EDB_MYSQLI::__construct ($host, $user, $pass, $db)
  51.     /** 
  52.      * Instantiates an EDB_MYSQLI object and opens an mysql database
  53.      *
  54.      * For examples:
  55.      * <code>
  56.      * $db = new EDB_MYSQLI ('mysqli://localhost', 'user', 'host', 'database');
  57.      * $db = new EDB_MYSQLI ('mysqli://localhost:3306', 'user', 'host', 'database');
  58.      * $db = new EDB_MYSQLI ('mysqli://localhost:/var/run/mysqld/mysql.socl', 'user', 'host', 'database');
  59.      * </code>
  60.      *
  61.      * If you add prefix 'p~' before host, you can connect with persistent
  62.      * connection.
  63.      *
  64.      * For Examples:
  65.      * <code>
  66.      * $db = new EDB_MYSQLI ('mysqli://p~localhost', 'user', 'host', 'database');
  67.      * </code>
  68.      *
  69.      * @access public
  70.      * @return EDB_MYSQLI 
  71.      * @param  string  $hostname mysql host
  72.      * @param  string  $user     mysql user
  73.      * @param  string  $password mysql password
  74.      * @param  string  $database mysql database
  75.      */
  76.     function __construct ({
  77.         $_argv func_get_args ();
  78.         $argv is_array ($_argv[0]$_argv[0$_argv;;
  79.  
  80.         if extension_loaded ('mysqli') )
  81.             throw new myException ('MySQLi extension is not loaded on PHP!'E_USER_ERROR);
  82.  
  83.         $o = (object) array (
  84.             'host' => preg_replace ('!^mysqli://!'''$argv[0]),
  85.             'user' => $argv[1],
  86.             'pass' => $argv[2],
  87.             'db'   => $argv[3]
  88.         );
  89.  
  90.         if preg_match ('/([^:]+):(.*)/'$o->host$matches) ) {
  91.             $o->host $matches[1];
  92.             $o->port $matches[2];
  93.         else
  94.             $o->port 3306;
  95.  
  96.         if is_numeric ($o->port) ) {
  97.             $o->sock $o->port;
  98.             $o->port 3306;
  99.         else
  100.             $o->sock null;
  101.  
  102.         // set persistent connect
  103.         $o->host preg_replace ('/^p~/''p:'$o->host);
  104.  
  105.         try {
  106.             $this->db new mysqli ($o->host$o->user$o->pass$o->db$o->port$o->sock);
  107.         catch Exception $e {
  108.             if mysqli_connect_error () )
  109.                 throw new myException (mysqli_connect_error ()E_USER_ERROR);
  110.             else
  111.                 throw new myException ($e->getMessage ()$e->getCode()$e);
  112.         }
  113.     }
  114.     // }}}
  115.  
  116.     // {{{ (string) EDB_MYSQLI::get_charset (void)
  117.     /** 
  118.      * Get character set of current database
  119.      *
  120.      * @access public
  121.      * @return string Current character set name on DB
  122.      */
  123.     function get_charset ({
  124.         try {
  125.             return $this->db->character_set_name ();
  126.         catch Exception $e {
  127.             throw new myException ($e->getMessage ()$e->getCode()$e);
  128.             return false;
  129.         }
  130.     }
  131.     // }}}
  132.  
  133.     // {{{ (bool) EDB_MYSQLI::set_charset ($charset)
  134.     /** 
  135.      * Set character set of current database
  136.      *
  137.      * @access public
  138.      * @return bool    The name of character set that is supported on database
  139.      * @param  string  name of character set that supported from database
  140.      */
  141.     function set_charset ($char{
  142.         try {
  143.             if is_object ($this->db) )
  144.                 return false;
  145.             return $this->db->set_charset ($char);
  146.         catch Exception $e {
  147.             throw new myException ($e->getMessage ()$e->getCode()$e);
  148.             return false;
  149.         }
  150.     }
  151.     // }}}
  152.  
  153.     // {{{ (string) EDB_MYSQLI::escape ($string)
  154.     /** 
  155.      * Escape special characters in a string for use in an SQL statement
  156.      *
  157.      * @access public
  158.      * @return string 
  159.      * @param  string  The string that is to be escaped.
  160.      */
  161.     function escape ($string{
  162.         return $this->db->real_escape_string ($string);
  163.     }
  164.     // }}}
  165.  
  166.     // {{{ (int) EDB_MYSQLI::query ($query, $param_type, $param1, $param2 ...)
  167.     /** 
  168.      * Performs a query on the database
  169.      *
  170.      * @access public
  171.      * @return integer The number of affected rows or false
  172.      * @param  string  $query The query strings
  173.      * @param  string  $type  (optional) Bind parameter type. See also
  174.      *  {@link http://php.net/manual/en/mysqli-stmt.bind-param.php mysqli_stmt::bind_param}.
  175.      *  <code>
  176.      *  i => integer
  177.      *  d => double
  178.      *  s => string
  179.      *  b => blob
  180.      *  </code>
  181.      * @param  mixed   $param1 (optional) Bind parameter 1
  182.      * @param  mixed   $param2,... (optional) Bind parameter 2 ..
  183.      */
  184.     function query ({
  185.         $_argv func_get_args ();
  186.         $argv is_array ($_argv[0]$_argv[0$_argv;;
  187.  
  188.         $this->error null;
  189.  
  190.         $sql array_shift ($argv);
  191.         $this->pno count ($argv$this->get_param_number ($sql0;
  192.  
  193.         if $this->free )
  194.             $this->free_result ();
  195.  
  196.         // store query in log variable
  197.         $this->queryLog[$sql;
  198.  
  199.         /*
  200.          * For no bind query
  201.          */
  202.         if $this->pno++ == )
  203.             return $this->no_bind_query ($sql);
  204.  
  205.         /*
  206.          * For bind query
  207.          */
  208.         return $this->bind_query ($sql$argv);
  209.     }
  210.     // }}}
  211.  
  212.     // {{{ (int) EDB_MYSQLI::lastId (void)
  213.     /**
  214.      * 마지막 실행한 쿼리에서 자동으로 생성된 ID(auto increment)값을 반환
  215.      *
  216.      * @since  2.0.4
  217.      * @access public
  218.      * @return integer|false
  219.      */
  220.     function lastId ({
  221.         return $this->db->insert_id;
  222.     }
  223.     // }}}
  224.  
  225.     // {{{ (bool) EDB_MYSQLI::seek ($offset)
  226.     /**
  227.      * Adjusts the result pointer to an arbitrary row in the result
  228.      *
  229.      * @access public
  230.      * @return boolean 
  231.      * @param  integer Must be between zero and the total number of rows minus one
  232.      */
  233.     function seek ($offset{
  234.         if is_object ($this->result) )
  235.             return false;
  236.  
  237.         try {
  238.             return $this->result->data_seek ($offset);
  239.         catch Exception $e {
  240.             throw new myException ($e->getMessage ()$e->getCode()$e);
  241.             return false;
  242.         }
  243.     }
  244.     // }}}
  245.  
  246.     // {{{ (object) EDB_MYSQLI::fetch (void)
  247.     /**
  248.      * Fetch a result row as an associative object
  249.      *
  250.      * @access public
  251.      * @return object The object of fetched a result row or false
  252.      * @param  boolean (optional) fetch 수행 후 result를 free한다.
  253.      *                  (기본값: false) EDB >= 2.0.3
  254.      */
  255.     function fetch ($free false{
  256.         try {
  257.             if $this->result instanceof mysqli_result )
  258.                 $r $this->fetch_result ();
  259.             else if $this->result instanceof mysqli_stmt )
  260.                 $r $this->fetch_stmt ();
  261.  
  262.             if $free )
  263.                 $this->free_result ();
  264.  
  265.             return $r;
  266.         catch Exception $e {
  267.             throw new myException ($e->getMessage ()$e->getCode()$e);
  268.             return false;
  269.         }
  270.         return false;
  271.     }
  272.     // }}}
  273.  
  274.     // {{{ (array) EDB_MYSQLI::fetch_all ($free = true)
  275.     /**
  276.      * Fetch all result rows as an associative object
  277.      *
  278.      * @access public
  279.      * @return array The fetched result rows
  280.      * @param  boolean (optional) free result set after fetch.
  281.      *                  Defaluts is true.
  282.      */
  283.     function fetch_all ($free true{
  284.         try {
  285.             if $this->result instanceof mysqli_result {
  286.                 return $this->fetch_result_all ($free);
  287.             else if $this->result instanceof mysqli_stmt {
  288.                 return $this->fetch_stmt_all ($free);
  289.             }
  290.         catch Exception $e {
  291.             throw new myException ($e->getMessage ()$e->getCode()$e);
  292.             return array ();
  293.         }
  294.  
  295.         return array ();
  296.     }
  297.     // }}}
  298.  
  299.     // {{{ (bool) EDB_MYSQLI::free_result (void)
  300.     /**
  301.      * Frees stored result memory for the given statement handle
  302.      *
  303.      * @access public
  304.      * @return boolean 
  305.      * @param  void 
  306.      */
  307.     function free_result ({
  308.         if $this->free return true;
  309.         $this->free = false;
  310.  
  311.         try {
  312.             if is_object ($this->result) )
  313.                 $this->result->free_result ();
  314.  
  315.             if $this->result instanceof mysqli_stmt )
  316.                 $this->result->close ();
  317.  
  318.             unset ($this->field);
  319.             $this->field array ();
  320.         catch Exception $e {
  321.             throw new myException ($e->getMessage ()$e->getCode()$e);
  322.             return false;
  323.         }
  324.  
  325.         return true;
  326.     }
  327.     // }}}
  328.  
  329.     // {{{ (string) EDB_MYSQLI::field_name ($index)
  330.     /**
  331.      * Get the name of the specified field in a result
  332.      *
  333.      * @access public
  334.      * @return string|false
  335.      * @param  integer The field number. This value must be in the
  336.      *                  range from 0 to number of fields - 1.
  337.      */
  338.     function field_name ($index{
  339.         try {
  340.             $r $this->field_info ($index'type');
  341.         catch Exception $e {
  342.             throw new myException ($e->getMessage ()$e->getCode()$e);
  343.             return false;
  344.         }
  345.  
  346.         return $r;
  347.     }
  348.     // }}}
  349.  
  350.     // {{{ (string) EDB_MYSQLI::field_type ($index)
  351.     /**
  352.      * Get the type of the specified field in a result
  353.      *
  354.      * @access public
  355.      * @return string|false
  356.      * @param  integer The numerical field offset. The field_offset starts
  357.      *                  at 0. If field_offset does not exist, return false
  358.      *                  and an error of level E_WARNING is also issued.
  359.      * @see http://php.net/manual/en/mysqli.constants.php Predefined Constants
  360.      */
  361.     function field_type ($index{
  362.         try {
  363.             $r $this->field_info ($index'type');
  364.         catch Exception $e {
  365.             throw new myException ($e->getMessage ()$e->getCode()$e);
  366.             return false;
  367.         }
  368.  
  369.         return $this->file_type_string ($r);
  370.     }
  371.     // }}}
  372.  
  373.     // {{{ (int) EDB_MYSQLI::num_fields (void)
  374.     /**
  375.      * Returns the number of columns for the most recent query
  376.      *
  377.      * @access public
  378.      * @return integer An integer representing the number of fields in a result set.
  379.      * @see http://php.net/manual/en/mysqli.field-count.php mysqli::$field_count
  380.      */
  381.     function num_fields ({
  382.         try {
  383.             return $this->db->field_count;
  384.         catch Exception $e {
  385.             throw new myException ($e->getMessage ()$e->getCode()$e);
  386.             return false;
  387.         }
  388.     }
  389.     // }}}
  390.  
  391.     // {{{ (void) EDB_MYSQLI::trstart (void)
  392.     /**
  393.      * DB transaction 을 시작한다.
  394.      *
  395.      * @access public
  396.      * @return void 
  397.      */
  398.     function trstart ({
  399.         //$this->db->query ('BEGIN');
  400.         $this->db->query ('START TRANSACTION WITH CONSISTENT SNAPSHOT');
  401.     }
  402.     // }}}
  403.  
  404.     // {{{ (void) EDB_MYSQLI::trend ($v)
  405.     /**
  406.      * DB transaction 을 종료한다.
  407.      *
  408.      * @access public
  409.      * @return void 
  410.      * @param bool false일경우 rollback을 수행한다.
  411.      */
  412.     function trend ($v true{
  413.         $sql ($v === false'ROLLBACK' 'COMMIT';
  414.         $this->db->query ($sql);
  415.     }
  416.     // }}}
  417.  
  418.     // {{{ (void) EDB_MYSQLI::close (void)
  419.     /**
  420.      * Close the db handle
  421.      *
  422.      * @access public
  423.      * @return void 
  424.      * @param  void 
  425.      */
  426.     function close ({
  427.         if is_object ($this->db) ) {
  428.             $this->db->close ();
  429.             unset ($this->db);
  430.         }
  431.     }
  432.     // }}}
  433.  
  434.     /*
  435.      * Priavte functions
  436.      */
  437.     // {{{ private (int) EDB_MYSQLI::no_bind_query ($sql)
  438.     /** 
  439.      * Performs a query on the database
  440.      *
  441.      * @access private
  442.      * @return integer The number of affected rows or false
  443.      * @param  string  The query strings
  444.      */
  445.     private function no_bind_query ($sql{
  446.         try {
  447.             $this->result = $this->db->query ($sql);
  448.             if $this->db->errno {
  449.                 $this->free = false;
  450.                 throw new myException ($this->db->errorE_USER_WARNING);
  451.                 return false;
  452.             }
  453.         catch Exception $e {
  454.             $this->free = false;
  455.             throw new myException ($e->getMessage ()$e->getCode()$e);
  456.             return false;
  457.         }
  458.  
  459.         $this->switch_freemark ();
  460.  
  461.         if preg_match ('/^(update|insert|delete|replace)/i'trim ($sql)) ) {
  462.             /* Insert or update, or delete query */
  463.             return $this->db->affected_rows;
  464.         else if preg_match ('/create|drop/i'trim ($sql)) ) {
  465.             return 1;
  466.         }
  467.  
  468.         return $this->result->num_rows;
  469.     }
  470.     // }}}
  471.  
  472.     // {{{ private (int) EDB_MYSQLI::bind_query ($sql, $parameters)
  473.     /** 
  474.      * Performs a bind query on the database
  475.      *
  476.      * @access private
  477.      * @return integer The number of affected rows or false
  478.      * @param  string  The query strings
  479.      * @param  array   (optional) Bind parameter type
  480.      */
  481.     private function bind_query ($sql$params{
  482.         if isset ($param) )
  483.             unset ($param);
  484.  
  485.         $this->result = $this->db->prepare ($sql);
  486.  
  487.         if $this->db->errno || is_object ($this->result) ) {
  488.             throw new myException ($this->db->errorE_USER_WARNING);
  489.             return false;
  490.         }
  491.  
  492.         $this->switch_freemark ();
  493.  
  494.         if $this->pno != count ($params|| $this->check_param ($params=== false {
  495.             $this->free_result ();
  496.             throw new myException (
  497.                 'Number of elements in query doesn\'t match number of bind variables',
  498.                 E_USER_WARNING
  499.             );
  500.             return false;
  501.         }
  502.  
  503.         $blobs array ();
  504.         for $i=0$i<count ($params)$i++ {
  505.             $param[$i&$params[$i];
  506.             if $i == )
  507.                 continue;
  508.  
  509.             switch ($params[0][$i-1]{
  510.                 case 'c' :
  511.                     // don't support clob type mysqli_bind_params
  512.                     $params[0][$i-1'b';
  513.                 case 'b' :
  514.                     $blobs[$i-1is_object ($params[$i]$params[$i]->data $params[$i];
  515.                     $params[$i]  null;
  516.                     break;
  517.             }
  518.         }
  519.  
  520.         try {
  521.             $r call_user_func_array (array ($this->result'bind_param')$param);
  522.             if $r === false )
  523.                 throw new myException ($this->result->errorE_USER_ERROR);
  524.  
  525.             # for blob data
  526.             foreach $blobs as $key => $val {
  527.                 if $this->result->send_long_data ($key$val=== false )
  528.                     throw new myException ($this->result->errorE_USER_ERROR);
  529.             }
  530.  
  531.             if $this->result->execute (=== false )
  532.                 throw new myException ($this->result->errorE_USER_ERROR);
  533.         catch Exception $e {
  534.             $this->free_result ();
  535.             throw new myException ($e->getMessage ()$e->getCode()$e);
  536.             return false;
  537.         }
  538.  
  539.         $this->bind_result ($sql);
  540.  
  541.         return $this->result->affected_rows;
  542.     }
  543.     // }}}
  544.  
  545.     // {{{ private (void) EDB_MYSQLI::bind_result (void)
  546.     /**
  547.      * Binds variables to a prepared statement for result storage
  548.      *
  549.      * @access private
  550.      * @return void 
  551.      * @param  string Query string
  552.      */
  553.     private function bind_result ($sql{
  554.         if preg_match ('/^(update|insert|delete)/i'trim ($sql)) )
  555.             return;
  556.  
  557.         unset ($this->field);
  558.         $this->field array ();
  559.  
  560.         try {
  561.             $this->result->store_result ();
  562.             $var array ();
  563.             $meta $this->result->result_metadata ();
  564.  
  565.             while $fields $meta->fetch_field () )
  566.                 $var[&$this->field[$fields->name];
  567.  
  568.             $meta->free ();
  569.             call_user_func_array(array($this->result'bind_result')$var);
  570.         catch Exception $e {
  571.             $this->free_result ();
  572.             throw new myException ($e->getMessage ()$e->getCode()$e);
  573.             return false;
  574.         }
  575.     }
  576.     // }}}
  577.  
  578.     // {{{ private (object) EDB_MYSQLI::fetch_result (void)
  579.     /**
  580.      * Fetch a result row as an associative object
  581.      *
  582.      * @access private
  583.      * @return object The object of fetched a result row or false
  584.      * @param  void 
  585.      */
  586.     private function fetch_result ({
  587.         if $this->result instanceof mysqli_result )
  588.             $r  $this->result->fetch_object ();
  589.         return is_object ($r$r false;
  590.     }
  591.     // }}}
  592.  
  593.     // {{{ private (object) EDB_MYSQLI::fetch_stmt (void)
  594.     /**
  595.      * Fetch a result row as an associative object
  596.      *
  597.      * @access private
  598.      * @return object The object of fetched a result row or false
  599.      * @param  void 
  600.      */
  601.     private function fetch_stmt ({
  602.         if $this->result instanceof mysqli_stmt )
  603.             return false;
  604.  
  605.         if $fetch_check $this->result->fetch () ) {
  606.             $retval new stdClass;
  607.             foreach $this->field as $key => $val )
  608.                 $retval->$key $val;
  609.         else
  610.             $retval false;
  611.  
  612.         return $retval;
  613.     }
  614.     // }}}
  615.  
  616.     // {{{ private (array) EDB_MYSQLI::fetch_result_all ($free = true)
  617.     /**
  618.      * Fetch all result rows as an associative object
  619.      *
  620.      * @access private
  621.      * @return array The fetched result rows
  622.      * @param  boolean (optional) free result set after fetch.
  623.      *                  Defaluts is true.
  624.      */
  625.     private function fetch_result_all ($free true{
  626.         if $this->result instanceof mysqli_result )
  627.             return array ();
  628.  
  629.         //$this->field = array ();
  630.         $rows array ();
  631.  
  632.         while ( ($row $this->result->fetch_object ()) !== null )
  633.             $rows[$row;
  634.  
  635.         if $free )
  636.             $this->free_result ();
  637.         return $rows;
  638.     }
  639.     // }}}
  640.  
  641.     // {{{ private (array) EDB_MYSQLI::fetch_stmt_all ($free = true)
  642.     /**
  643.      * Fetch all result rows as an associative object
  644.      *
  645.      * @access public
  646.      * @return array The fetched result rows
  647.      * @param  boolean (optional) free result set after fetch.
  648.      *                  Defaluts is true.
  649.      */
  650.     private function fetch_stmt_all ($free true{
  651.         if $this->result instanceof mysqli_stmt )
  652.             return array ();
  653.  
  654.         $r array ();
  655.  
  656.         $i 0;
  657.         while $this->result->fetch () ) {
  658.             $r[$inew stdClass;
  659.             foreach $this->field as $key => $val )
  660.                 $r[$i]->$key $val;
  661.             $i++;
  662.         }
  663.  
  664.         if $free)
  665.             $this->free_result ();
  666.  
  667.         return $r;
  668.     }
  669.     // }}}
  670.  
  671.     // {{{ private (mixed) EDB_MYSQLI::field_info ($index)
  672.     /**
  673.      * Get the type of the specified field in a result
  674.      *
  675.      * @access private
  676.      * @return mixed|false
  677.      * @param  integer The numerical field offset. The field_offset starts
  678.      *                  at 0. If field_offset does not exist, return false
  679.      *                  and an error of level E_WARNING is also issued.
  680.      */
  681.     private function field_info ($index$type 'name'{
  682.         try {
  683.             $r false;
  684.  
  685.             if $this->result instanceof mysqli_result {
  686.                 if ( ($o $this->result->fetch_field_direct ($index)) === false )
  687.                     return false;
  688.                 $r $o->$type;
  689.             else if $this->result instanceof mysqli_stmt {
  690.                 if ( ($result $this->result->result_metadata ()) === false )
  691.                     return false;
  692.  
  693.                 for $i=0$i<=$index$i++ )
  694.                     $o $result->fetch_field ();
  695.                 $r $o->$type;
  696.                 $result->free_result ();
  697.             }
  698.  
  699.             return $r;
  700.         catch Exception $e {
  701.             throw new myException ($e->getMessage ()$e->getCode()$e);
  702.             return false;
  703.         }
  704.     }
  705.     // }}}
  706.  
  707.     // {{{ private (string) file_type_string ($type) {
  708.     /**
  709.      * change mysqli filed type to strings
  710.      *
  711.      * @access private
  712.      * @return string 
  713.      * @param  integer mysqli field type
  714.      */
  715.     private function file_type_string ($type{
  716.         switch ($type{
  717.             case MYSQLI_TYPE_DECIMAL :
  718.                 return 'DECIMAL';
  719.             //Precision math DECIMAL or NUMERIC field (MySQL 5.0.3 and up)
  720.             case MYSQLI_TYPE_NEWDECIMAL :
  721.                 return 'NUMERIC';
  722.             case MYSQLI_TYPE_BIT :
  723.                 return 'BIT (MySQL 5.0.3 and up)';
  724.             case MYSQLI_TYPE_TINY :
  725.                 return 'TINYINT';
  726.             case MYSQLI_TYPE_SHORT :
  727.                 return 'SMALLINT';
  728.             case MYSQLI_TYPE_LONG :
  729.                 return 'INT';
  730.             case MYSQLI_TYPE_FLOAT :
  731.                 return 'FLOAT';
  732.             case MYSQLI_TYPE_DOUBLE :
  733.                 return 'DOUBLE';
  734.             case MYSQLI_TYPE_NULL :
  735.                 return 'DEFAULT NULL';
  736.             case MYSQLI_TYPE_TIMESTAMP :
  737.                 return 'TIMESTAMP';
  738.             case MYSQLI_TYPE_LONGLONG :
  739.                 return 'BIGINT';
  740.             case MYSQLI_TYPE_INT24 :
  741.                 return 'MEDIUMINT';
  742.             case MYSQLI_TYPE_DATE :
  743.                 return 'DATE';
  744.             case MYSQLI_TYPE_TIME :
  745.                 return 'TIME';
  746.             case MYSQLI_TYPE_DATETIME :
  747.                 return 'DATETIME';
  748.             case MYSQLI_TYPE_YEAR :
  749.                 return 'YEAR';
  750.             case MYSQLI_TYPE_NEWDATE :
  751.                 return 'DATE';
  752.             case MYSQLI_TYPE_INTERVAL :
  753.                 return 'INTERVAL';
  754.             case MYSQLI_TYPE_ENUM :
  755.                 return 'ENUM';
  756.             case MYSQLI_TYPE_SET :
  757.                 return 'SET';
  758.             case MYSQLI_TYPE_TINY_BLOB :
  759.                 return 'TINYBLOB';
  760.             case MYSQLI_TYPE_MEDIUM_BLOB :
  761.                 return 'MEDIUMBLOB';
  762.             case MYSQLI_TYPE_LONG_BLOB :
  763.                 return 'LONGBLOB';
  764.             case MYSQLI_TYPE_BLOB :
  765.                 return 'BLOB';
  766.             case MYSQLI_TYPE_VAR_STRING :
  767.                 return 'VARCHAR';
  768.             case MYSQLI_TYPE_STRING :
  769.                 return 'STRING';
  770.             case MYSQLI_TYPE_CHAR :
  771.                 return 'CHAR';
  772.             case MYSQLI_TYPE_GEOMETRY :
  773.                 return 'GEOMETRY';
  774.             default:
  775.                 return 'UNKNOWN';
  776.         }
  777.     }
  778.     // }}}
  779.  
  780.     function __destruct ({
  781.         try {
  782.             $this->free_result ();
  783.             $this->close ();
  784.         catch Exception $e }
  785.     }
  786. }
  787.  
  788. /*
  789.  * Local variables:
  790.  * tab-width: 4
  791.  * c-basic-offset: 4
  792.  * End:
  793.  * vim: set filetype=php noet sw=4 ts=4 fdm=marker:
  794.  * vim600: noet sw=4 ts=4 fdm=marker
  795.  * vim<600: noet sw=4 ts=4
  796.  */
  797. ?>

Documentation generated on Tue, 14 May 2019 01:59:53 +0900 by phpDocumentor 1.4.4