Beispiel #1
0
 /**
  * Initialize object
  * @param string $module module name
  * @param string $dbname database name alias in configuration file
  * @param string $table database table name
  * @param array $opts more option
  * @return void
  */
 function __construct($module, $dbname, $table, $opts)
 {
     $this->module = $module;
     $this->dbname = $dbname;
     $this->table = $table;
     $this->opts = $opts;
     $this->dbConfig = BizSystem::configuration()->getDatabaseInfo($dbname);
 }
Beispiel #2
0
 protected function dbs()
 {
     $dbinfo = BizSystem::configuration()->getDatabaseInfo();
     $i = 0;
     foreach ($dbinfo as $db) {
         $list[$i]['val'] = $db['Name'];
         $list[$i]['txt'] = $db['Name'];
         $i++;
     }
     return $list;
 }
 /**
  * Build insert-sql
  * INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....)
  *
  * @param BizDataObj $dataObj
  * @param array $joinValues array of join values
  * @return string Insert-SQL statement
  */
 public function buildInsertSQL($dataObj, $joinValues = null)
 {
     // generate column value pairs.
     $sqlFlds = $dataObj->m_BizRecord->getToSaveFields('CREATE');
     $dbInfo = BizSystem::configuration()->getDatabaseInfo($dataObj->m_Database);
     $dbType = $dbInfo["Driver"];
     $sql_col = "";
     $sql_val = "";
     $db = $dataObj->getDBConnection('WRITE');
     foreach ($sqlFlds as $fldobj) {
         $col = $fldobj->m_Column;
         // if Field Id has null value and Id is an identity type, remove the Id's column from the array
         if ($fldobj->m_Name == "Id" && $dataObj->m_IdGeneration == "Identity") {
             continue;
         }
         if ($fldobj->isLobField()) {
             // special value for blob/clob type
             $_val = $fldobj->getInsertLobValue($dbType);
         } else {
             $_val = $fldobj->getSqlValue();
             if ($_val == '' && $fldobj->m_ValueOnCreate != "") {
                 $_val = $fldobj->getValueOnCreate();
             }
         }
         //if (!$_val || $_val == '') continue;
         // modified by jixian for not ignore 0 value
         if ($_val === '') {
             continue;
         }
         $sql_col .= "`" . $col . "`, ";
         $sql_val .= $db->quote($_val) . ", ";
         //$sql_val .= QueryStringParam::formatQueryValue($_val). ", ";
     }
     // if joinValues is given then add join values in to the main table InsertSQL.
     if (is_array($joinValues)) {
         foreach ($joinValues as $joinColumn => $joinValue) {
             if (!$joinValue || $joinValue == '') {
                 continue;
             }
             $sql_col .= "`" . $joinColumn . "`, ";
             $sql_val .= "'" . $joinValue . "', ";
         }
     }
     $sql_col = substr($sql_col, 0, -2);
     $sql_val = substr($sql_val, 0, -2);
     $sql = "INSERT INTO  `" . $dataObj->m_MainTable . "` (" . $sql_col . ") VALUES (" . $sql_val . ")";
     return $sql;
 }
Beispiel #4
0
 /**
  * set char to quote system identifiers
  * @return void
  */
 protected function setQuoteIdentifiers($dataObj)
 {
     if ($this->m_QuoteIdentifiers == null) {
         $this->m_QuoteIdentifiers = '';
         $dbInfo = BizSystem::configuration()->getDatabaseInfo($dataObj->m_Database);
         if (strtoupper($dbInfo["Driver"]) == "PDO_MYSQL") {
             $this->m_QuoteIdentifiers = '`';
         }
     }
 }