コード例 #1
0
	function InsertMultiple($strTable, $arrSingle)
	{
            $odbcreturnid = -1;
            if ((count($arrSingle) > 0) && ($this->conn))
            {
                $strInsert = "insert into $strTable (";
                $strKeys = "";
                for ($i = 0; $i < count($arrSingle); $i++)
                {
                    $strVals = "";
                    foreach($arrSingle[$i] as $key => $val)
                    {
                        if ($i == 0)
                        {
                            $strKeys[] = $key;
                        }
                        $strVals[] = $val;
                    }
                    $strMultipleVals[] = "('" . implode("','", $strVals) . "')";
                }
                //print_r($strKeys);
                $strInsert .= implode("," , $strKeys) . ") values " . implode("," , $strMultipleVals );
                odbc_query($strInsert);
            }
            return $odbcreturnid;
	}
コード例 #2
0
 /**
  * Execute a query
  * @param string $query  query
  * @param boolean $is_manip  if the query is a manipulation query
  * @param resource $connection
  * @param string $database_name
  * @return result or error object
  * @access protected
  */
 function &_doQuery($query, $is_manip = false, $connection = null, $database_name = null)
 {
     // echo "<hr>".$query."<br>\n";
     $this->last_query = $query;
     $result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre'));
     if ($result) {
         if (PEAR::isError($result)) {
             return $result;
         }
         $query = $result;
     }
     if ($this->options['disable_query']) {
         $result = $is_manip ? 0 : null;
         return $result;
     }
     if (is_null($connection)) {
         $connection = $this->getConnection();
         if (PEAR::isError($connection)) {
             return $connection;
         }
     }
     if (is_null($database_name)) {
         $database_name = $this->database_name;
     }
     if ($database_name) {
         if ($database_name != $this->connected_database_name) {
             /*
             if (!odbc_select_db($database_name, $connection)) {
                 $err = $this->raiseError(null, null, null,
                     'Could not select the database: '.$database_name, __FUNCTION__);
                 return $err;
             }
             */
             $this->connected_database_name = $database_name;
         }
     }
     $result = odbc_query($query, $connection);
     if (!$result) {
         $err =& $this->raiseError(null, null, null, 'Could not execute statement', __FUNCTION__);
         return $err;
     }
     $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'post', 'result' => $result));
     //print_r(odbc_fetch_array($result));
     return $result;
 }