Example #1
0
/**
 * PHP Template.
 */
function updateSF($tableName, $rowID, $sfID)
{
    $odbc = odbcConnect();
    $stmt = odbc_prepare($odbc, "INSERT into SalesForceUpdateQueue (creationDate, mysqlTableName, mysqlRowID, salesForceID) VALUES(CURRENT_TIMESTAMP(), ?, ?, ?)");
    $rs = odbc_execute($stmt, array($tableName, $rowID, $sfID));
    odbc_close($odbc);
}
Example #2
0
 public function insert_id($insertSql)
 {
     $query = odbc_execute($this->dbConnection(), $insertSql);
     if ($query) {
         return $query;
     } else {
         $this->halt('Database query error', $insertSql);
     }
 }
Example #3
0
 protected function _exec($sql, $params = array())
 {
     $this->_stmt = odbc_prepare($this->_con, $sql);
     if ($this->_stmt === false) {
         $this->raiseError($this->_stmt, $params);
     }
     $res = odbc_execute($this->_stmt, $params);
     if ($res === false) {
         $this->raiseError($sql, $params);
     }
     return $res;
 }
Example #4
0
 /**
  * Executes the supplied SQL statement and returns
  * the result of the call.
  * 
  * @access  public
  *  
  * @param   string  SQL to execute
  */
 function exec()
 {
     if (func_num_args() > 1) {
         $args = func_get_args();
         $sql = $args[0];
         unset($args[0]);
         // remove the sql
         $args = array_values($args);
         // and reset the array index
     } else {
         $sql = func_get_arg(0);
     }
     $this->ensureConnection();
     if (isset($args)) {
         $result = odbc_prepare($this->connection, $sql);
         if (!odbc_execute($result, $args)) {
             throw new Exception(odbc_errormsg($this->connection));
         }
         return odbc_num_rows($result);
     } else {
         return odbc_exec($this->connection, $sql);
     }
 }
 /**
  * Internal function to call native ODBC prepare/execute functions.
  */
 protected function _execute($sql, $params, $fetchmode, $isupdate)
 {
     // Set any params passed directly
     if ($params) {
         for ($i = 0, $cnt = count($params); $i < $cnt; $i++) {
             $this->set($i + 1, $params[$i]);
         }
     }
     // Trim surrounding quotes added from default set methods.
     // Exception: for LOB-based parameters, odbc_execute() will
     // accept a filename surrounded by single-quotes.
     foreach ($this->boundInVars as $idx => $var) {
         if ($var instanceof Lob) {
             $file = $isupdate ? $var->getInputFile() : $var->getOutputFile();
             $this->boundInVars[$idx] = "'{$file}'";
         } else {
             if (is_string($var)) {
                 $this->boundInVars[$idx] = trim($var, "\"\\'");
             }
         }
     }
     if ($this->resultSet) {
         $this->resultSet->close();
         $this->resultSet = null;
     }
     $this->updateCount = null;
     $stmt = @odbc_prepare($this->conn->getResource(), $sql);
     if ($stmt === FALSE) {
         throw new SQLException('Could not prepare query', $this->conn->nativeError(), $sql);
     }
     $ret = @odbc_execute($stmt, $this->boundInVars);
     if ($ret === FALSE) {
         @odbc_free_result($stmt);
         throw new SQLException('Could not execute query', $this->conn->nativeError(), $sql);
     }
     return $this->conn->createResultSet(new ODBCResultResource($stmt), $fetchmode);
 }
Example #6
0
 function get_report(client $client, $table_name, $show, $rownum)
 {
     if ($table_name == null) {
         return "Bad table name.";
     }
     //TODO check table_name is one word
     //compile query
     $colnames = odbc_exec($client->get_connection(), "SELECT column_name, data_type, data_length FROM ALL_TAB_COLUMNS WHERE table_name = '" . strtoupper($table_name) . "';");
     if ($colnames === false) {
         return "Unable to get table fields.";
     }
     $query = "SELECT ";
     $i = 0;
     while (odbc_fetch_row($colnames)) {
         if (isset($show) && isset($show[$i]) && $show[$i] == true) {
             if ($query != "SELECT ") {
                 $query .= ", ";
             }
             $query .= odbc_result($colnames, 1);
         }
         $i += 1;
     }
     $query .= " FROM " . $table_name . " WHERE rownum <= ?;";
     //prepare statement
     $statement = odbc_prepare($client->get_connection(), $query);
     if ($statement === false) {
         return $query . "\n\n" . get_odbc_error();
     }
     $items = array();
     $items[] = (int) $rownum;
     $result = odbc_execute($statement, $items);
     if ($result === false) {
         return $query . "\n\n" . get_odbc_error();
     }
     return $statement;
 }
Example #7
0
 function DoQuery($query, $first = 0, $limit = 0, $prepared_query = 0)
 {
     if ($prepared_query && isset($this->query_parameters[$prepared_query]) && count($this->query_parameters[$prepared_query])) {
         if ($result = @odbc_prepare($this->connection, $query)) {
             if (!@odbc_execute($result, $this->query_parameters[$prepared_query])) {
                 $this->SetODBCError("Do query", "Could not execute a ODBC database prepared query \"{$query}\"", $php_errormsg);
                 odbc_free_result($result);
                 return 0;
             }
         } else {
             $this->SetODBCError("Do query", "Could not execute a ODBC database prepared query \"{$query}\"", $php_errormsg);
             return 0;
         }
     } else {
         $result = @odbc_exec($this->connection, $query);
     }
     if ($result) {
         $this->current_row[$result] = -1;
         if (substr(strtolower(ltrim($query)), 0, strlen("select")) == "select") {
             $result_value = intval($result);
             $this->current_row[$result_value] = -1;
             if ($limit > 0) {
                 $this->limits[$result_value] = array($first, $limit, 0);
             }
             $this->highest_fetched_row[$result_value] = -1;
         } else {
             $this->affected_rows = odbc_num_rows($result);
             odbc_free_result($result);
         }
     } else {
         $this->SetODBCError("Do query", "Could not execute a ODBC database query \"{$query}\"", $php_errormsg);
     }
     return $result;
 }
Example #8
0
 /**
  * Returns the mappings for the given template
  * The result has the form Map<String, List<PropertyAnnotation>>
  *
  */
 private function getPropertyAnnotations($templateId)
 {
     Timer::start('LiveMappingBasedExtractor::getPropertyAnnotations');
     $query = "SELECT " . "name, renamedValue, parseHint, isIgnored " . "FROM " . TBLPROPERTYANNOTATION . " a Join " . TBLPROPERTYMAPPING . " b On (a.id = b.parent_id) " . "WHERE " . "a.parent_id = ?";
     $this->log(DEBUG, str_replace('?', $templateId . ";", $query));
     $stmt = $this->odbc->prepare($query, get_class($this));
     odbc_execute($stmt, array($templateId));
     $result = array();
     while (odbc_fetch_row($stmt)) {
         $name = odbc_result($stmt, "name");
         $parseHint = odbc_result($stmt, "parseHint");
         $renamedValue = odbc_result($stmt, "renamedValue");
         $isIgnored = odbc_result($stmt, "isIgnored");
         $pa = null;
         if (!array_key_exists($name, $result)) {
             $pa = new PropertyAnnotation($name, $isIgnored);
             $result[$name] = $pa;
         } else {
             $pa = $result[$name];
         }
         $pm = new PropertyMapping($renamedValue, $parseHint);
         $pa->addMapping($pm);
     }
     Timer::stop('LiveMappingBasedExtractor::getPropertyAnnotations');
     return $result;
 }
Example #9
0
 /**
  * Execute an sql query
  */
 public function query($query, array $params = null)
 {
     # If the next query should be cached then run the cache function instead
     if ($this->cacheNext) {
         $this->cacheNext = false;
         return $this->cache($query, $params);
     }
     # Ensure we have a connection to run this query on
     $this->connect();
     $this->query = $query;
     $this->params = null;
     $this->preparedQuery = false;
     if (is_array($params)) {
         $this->params = $params;
     }
     $this->quoteChars($query);
     $this->functions($query);
     $this->limit($query);
     $this->tableNames($query);
     $this->namedParams($query, $params);
     $this->paramArrays($query, $params);
     $this->convertNulls($params);
     $preparedQuery = $this->prepareQuery($query, $params);
     $this->preparedQuery = $preparedQuery;
     if ($this->output) {
         if ($this->htmlMode) {
             echo "<pre>";
         }
         echo $preparedQuery;
         if ($this->htmlMode) {
             echo "<hr>";
         } else {
             echo "\n";
         }
     }
     switch ($this->mode) {
         case "mysql":
             if (!($result = $this->server->query($preparedQuery))) {
                 $this->error();
             }
             break;
         case "postgres":
         case "redshift":
             $tmpQuery = $query;
             $query = "";
             $noParams = false;
             if ($this->mode == "redshift" && count($params) > 32767) {
                 $noParams = true;
             }
             $i = 1;
             reset($params);
             while ($pos = strpos($tmpQuery, "?")) {
                 if ($noParams) {
                     $query .= substr($tmpQuery, 0, $pos) . "'" . pg_escape_string(current($params)) . "'";
                     next($params);
                 } else {
                     $query .= substr($tmpQuery, 0, $pos) . "\$" . $i++;
                 }
                 $tmpQuery = substr($tmpQuery, $pos + 1);
             }
             $query .= $tmpQuery;
             $params = Helper::toArray($params);
             if (!($result = pg_query_params($this->server, $query, $params))) {
                 $this->error();
             }
             break;
         case "odbc":
             if (!($result = odbc_prepare($this->server, $query))) {
                 $this->error();
             }
             $params = Helper::toArray($params);
             if (!odbc_execute($result, $params)) {
                 $this->error();
             }
             break;
         case "sqlite":
             if (!is_array($params)) {
                 if (!($result = $this->server->query($preparedQuery))) {
                     $this->error();
                 }
                 # If we have some parameters then we must convert them to the sqlite format
             } else {
                 $newQuery = "";
                 foreach ($params as $key => $val) {
                     $pos = strpos($query, "?");
                     $newQuery .= substr($query, 0, $pos);
                     $query = substr($query, $pos + 1);
                     $newQuery .= ":var" . $key;
                 }
                 $newQuery .= $query;
                 if (!($result = $this->server->prepare($newQuery))) {
                     $this->error();
                 }
                 foreach ($params as $key => $val) {
                     switch (gettype($val)) {
                         case "boolean":
                         case "integer":
                             $type = SQLITE3_INTEGER;
                             break;
                         case "double":
                             $type = SQLITE3_FLOAT;
                             break;
                         case "NULL":
                             if ($this->allowNulls) {
                                 $type = SQLITE3_NULL;
                             } else {
                                 $type = SQLITE3_TEXT;
                                 $val = "";
                             }
                             break;
                         default:
                             $type = SQLITE3_TEXT;
                     }
                     $result->bindValue(":var" . $key, $val, $type);
                 }
                 if (!($result = $result->execute())) {
                     $this->error();
                 }
             }
             break;
         case "mssql":
             if (!($result = mssql_query($preparedQuery, $this->server))) {
                 $this->error();
             }
             break;
     }
     if (!$result) {
         $this->error();
     }
     return new Result($result, $this->mode);
 }
 function _query($sql, $inputarr = false)
 {
     global $php_errormsg;
     if (isset($php_errormsg)) {
         $php_errormsg = '';
     }
     $this->_error = '';
     if ($inputarr) {
         if (is_array($sql)) {
             $stmtid = $sql[1];
         } else {
             $stmtid = odbc_prepare($this->_connectionID, $sql);
             if ($stmtid == false) {
                 $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
                 return false;
             }
         }
         if (!odbc_execute($stmtid, $inputarr)) {
             //@odbc_free_result($stmtid);
             if ($this->_haserrorfunctions) {
                 $this->_errorMsg = odbc_errormsg();
                 $this->_errorCode = odbc_error();
             }
             if ($this->_errorCode == '00000') {
                 // MS SQL Server sometimes returns this in combination with the FreeTDS
                 $this->_errorMsg = '';
                 // driver and UnixODBC under Linux. This fixes the bogus "error"
                 $this->_errorCode = 0;
                 // <*****@*****.**>
                 return true;
             }
             return false;
         }
     } else {
         if (is_array($sql)) {
             $stmtid = $sql[1];
             if (!odbc_execute($stmtid)) {
                 //@odbc_free_result($stmtid);
                 if ($this->_haserrorfunctions) {
                     $this->_errorMsg = odbc_errormsg();
                     $this->_errorCode = odbc_error();
                 }
                 if ($this->_errorCode == '00000') {
                     // MS SQL Server sometimes returns this in combination with the FreeTDS
                     $this->_errorMsg = '';
                     // driver and UnixODBC under Linux. This fixes the bogus "error"
                     $this->_errorCode = 0;
                     // <*****@*****.**>
                     return true;
                 }
                 return false;
             }
         } else {
             $stmtid = odbc_exec($this->_connectionID, $sql);
         }
     }
     $this->_lastAffectedRows = 0;
     if ($stmtid) {
         if (@odbc_num_fields($stmtid) == 0) {
             $this->_lastAffectedRows = odbc_num_rows($stmtid);
             $stmtid = true;
         } else {
             $this->_lastAffectedRows = 0;
             odbc_binmode($stmtid, $this->binmode);
             odbc_longreadlen($stmtid, $this->maxblobsize);
         }
         if ($this->_haserrorfunctions) {
             $this->_errorMsg = '';
             $this->_errorCode = 0;
         } else {
             $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
         }
     } else {
         if ($this->_haserrorfunctions) {
             $this->_errorMsg = odbc_errormsg();
             $this->_errorCode = odbc_error();
         } else {
             $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
         }
     }
     return $stmtid;
 }
Example #11
0
}
# With (default) debug mode, the following statements will generate
# annoying "cursor updatability" warnings.
$rv = odbc_execute($stmt, array(2, 'two'));
if ($rv != 1) {
    exit("2nd Insertion failed with  value {$rv}\n");
}
$rv = odbc_execute($stmt, array(3, 'three'));
if ($rv != 1) {
    exit("3rd Insertion failed with  value {$rv}\n");
}
$rv = odbc_execute($stmt, array(4, 'four'));
if ($rv != 1) {
    exit("4th Insertion failed with  value {$rv}\n");
}
$rv = odbc_execute($stmt, array(5, 'five'));
if ($rv != 1) {
    exit("5th Insertion failed with  value {$rv}\n");
}
odbc_commit($conn_id);
# A non-parameterized query
$rs = odbc_exec($conn_id, "SELECT * FROM tsttbl WHERE id < 3");
if (!$rs) {
    exit("Error in SQL\n");
}
$rownum = 0;
while (odbc_fetch_row($rs)) {
    $rownum++;
    echo "{$rownum}: " . odbc_result($rs, "id") . '|' . odbc_result($rs, "vc") . '|' . odbc_result($rs, "entrytime") . "\n";
}
# You need to use the PDO_ODBC extension to parameterize queries (selects).
Example #12
0
 function _query($sql, $inputarr = false)
 {
     global $php_errormsg;
     $php_errormsg = '';
     $this->_error = '';
     if ($inputarr) {
         if (is_resource($sql)) {
             $stmtid = $sql;
         } else {
             $stmtid = odbc_prepare($this->_connectionID, $sql);
         }
         if ($stmtid == false) {
             $this->_errorMsg = $php_errormsg;
             return false;
         }
         //print_r($inputarr);
         if (!odbc_execute($stmtid, $inputarr)) {
             @odbc_free_result($stmtid);
             return false;
         }
     } else {
         $stmtid = odbc_exec($this->_connectionID, $sql);
     }
     if ($stmtid) {
         odbc_binmode($stmtid, $this->binmode);
         odbc_longreadlen($stmtid, $this->maxblobsize);
     }
     $this->_errorMsg = $php_errormsg;
     return $stmtid;
 }
Example #13
0
 /**
  * Executes the statement in unbuffered mode (if possible)
  * 
  * @internal
  * 
  * @param  fUnbufferedResult $result     The object to place the result into
  * @param  array             $params     The parameters for the statement
  * @param  mixed             &$extra     A variable to place extra information needed by some database extensions
  * @param  boolean           $different  If this statement is different than the last statement run on the fDatabase instance
  * @return void
  */
 public function executeUnbufferedQuery($result, $params, &$extra, $different)
 {
     if ($different && $this->used) {
         $this->regenerateStatement();
     }
     $this->used = TRUE;
     $extension = $this->database->getExtension();
     $connection = $this->database->getConnection();
     $statement = $this->statement;
     $params = $this->prepareParams($params);
     // For the extensions that require the statement be passed to the result
     // object, we store it in a stdClass object so the result object knows
     // not to free it when done
     $statement_holder = new stdClass();
     $statement_holder->statement = NULL;
     switch ($extension) {
         case 'ibm_db2':
             $extra = $statement;
             if (db2_execute($statement, $params)) {
                 $statement_holder->statement = $statement;
             } else {
                 $result->setResult(FALSE);
             }
             break;
         case 'mssql':
             $result->setResult(mssql_query($result->getSQL(), $this->connection, 20));
             break;
         case 'mysql':
             $result->setResult(mysql_unbuffered_query($result->getSQL(), $this->connection));
             break;
         case 'mysqli':
             $extra = $this->statement;
             if ($statement->execute()) {
                 $statement_holder->statement = $statement;
             } else {
                 $result->setResult(FALSE);
             }
             break;
         case 'oci8':
             $result->setResult(oci_execute($statement, $this->database->isInsideTransaction() ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS));
             break;
         case 'odbc':
             $extra = odbc_execute($statement, $params);
             if ($extra) {
                 odbc_longreadlen($statement, 1048576);
                 odbc_binmode($statement, ODBC_BINMODE_CONVERT);
                 $statement_holder->statement = $statement;
             } else {
                 $result->setResult($extra);
             }
             break;
         case 'pgsql':
             $result->setResult(pg_execute($connection, $this->identifier, $params));
             break;
         case 'sqlite':
             $result->setResult(sqlite_unbuffered_query($connection, $this->database->escape($statement, $params), SQLITE_ASSOC, $extra));
             break;
         case 'sqlsrv':
             $extra = sqlsrv_execute($statement);
             if ($extra) {
                 $statement_holder->statement = $statement;
             } else {
                 $result->setResult($extra);
             }
             break;
         case 'pdo':
             $extra = $statement->execute();
             if ($extra) {
                 $result->setResult($statement);
             } else {
                 $result->setResult($extra);
             }
             break;
     }
     if ($statement_holder->statement) {
         $result->setResult($statement_holder);
     }
     return $result;
 }
 private function _odbc_ttlp_execute($ntriples, $graphURI)
 {
     $odbc_result = false;
     if (Options::getOption('dryRun')) {
         $virtuosoPl = "DB.DBA.TTLP_MT (\n'{$ntriples}', '{$graphURI}', '{$graphURI}', 255)";
         $this->log(INFO, $virtuosoPl);
         $odbc_result = true;
     } else {
         $virtuosoPl = "DB.DBA.TTLP_MT (?, '{$graphURI}', '{$graphURI}', 255)";
         $stmt = $this->odbc->prepare($virtuosoPl, 'LiveUpdateDestination');
         $odbc_result = odbc_execute($stmt, array($ntriples));
         if ($odbc_result == false) {
             $this->log(ERROR, 'ttlp insert failes');
             $this->log(ERROR, $virtuosoPl);
             $this->log(ERROR, substr(odbc_errormsg(), 0, 100));
             $this->log(ERROR, substr($ntriples, 0, 100));
         } else {
             $this->log(INFO, 'insert returned a true via odbc_execute');
         }
         //old line, now we use odbc_prepare
         //$result = $this->odbc->exec( $virtuosoPl,'LiveUpdateDestination');
         $this->counterTotalODBCOperations += 1;
         $this->log(TRACE, $virtuosoPl);
     }
     return $odbc_result;
 }
 function deleteFromODBC($sql, $params)
 {
     $results = odbc_prepare($this->conn, $sql);
     if ($results === false) {
         // throw new ErrorException(odbc_errormsg());
         return false;
     }
     if (odbc_execute($results, $params) === false) {
         return false;
         //throw new ErrorException(odbc_errormsg());
     }
     return $results;
 }
Example #16
0
        $res = odbc_exec($conn, "delete from php_test");
        odbc_free_result($res);
        error_reporting(1);
        ?>
 - OK<p>
Inserting into table "php_test"
<?php 
        $sqlfloat = '00.0';
        $sqlint = 1000;
        $stmt = odbc_prepare($conn, "insert into php_test values(?,?,?,?)");
        for ($i = 1; $i <= 5; $i++) {
            $values[0] = "test-{$i}";
            $values[1] = $sqlint + $i;
            $values[2] = $i . $sqlfloat . $i;
            $values[3] = "php - values {$i}";
            $ret = odbc_execute($stmt, &$values);
        }
        odbc_free_result($stmt);
        $res = odbc_exec($conn, "select count(*) from php_test");
        if ($res && odbc_result($res, 1) == 5) {
            odbc_free_result($res);
            ?>
 - OK<p>
<H3>The table "php_test" should now contain the following values:</H3>
<table>
 <tr>
  <th>A</th><th>B</th><th>C</th><th>D</th>
 </tr>
 <tr>
  <td>test-1</td><td>1001</td><td>100.01</td><td>php - values 1</td>
 </tr>
Example #17
0
 /**
  * Execute a query command in RDBMS
  *
  * @param string $query Query command to execute
  * @param array $params Array of parameters in query (default = null)
  * @return object | false
  */
 public function query($query, $params = null)
 {
     $resultSet = null;
     if (is_null($params)) {
         if ($resultSet = @odbc_exec($this->_connection, $query)) {
             return $resultSet;
         } else {
             $this->_errorCode = odbc_error($this->_connection) . '-' . odbc_errormsg($this->_connection);
             return false;
         }
     } else {
         if ($prepared_stmt = @odbc_prepare($this->_connection, $query)) {
             $resultSet = @odbc_execute($prepared_stmt, $params);
             if ($resultSet) {
                 return $prepared_stmt;
             } else {
                 $this->_errorCode = odbc_error($this->_connection) . '-' . odbc_errormsg($this->_connection);
                 return false;
             }
         } else {
             $this->_errorCode = odbc_error($this->_connection) . '-' . odbc_errormsg($this->_connection);
             return false;
         }
     }
 }
 /**
  * Prepares SQL query as a statement and executes it with bind parameters
  *
  * @param string $sql        Given SQL query
  * @param array  $parameters Parameters to bind (optional in case you don't have placeholders in your query)
  *
  * @return bool
  * @throws VerticaQueryException
  * @author Sergii Katrych <*****@*****.**>
  */
 protected function prepareAndExecute($sql, array $parameters = array())
 {
     $stmt = odbc_prepare($this->getConnection(), $sql);
     if (false === $stmt) {
         throw new VerticaQueryException(odbc_errormsg($this->getConnection()), odbc_error($this->getConnection()));
     }
     // @TODO: validate and quote $parameters values
     $result = odbc_execute($stmt, $parameters);
     if (false === $result) {
         return false;
     }
     return odbc_num_rows($stmt);
 }
Example #19
0
 /**
  * Execute the query
  *
  * @param	string	$sql	an SQL query
  * @return	resource
  */
 protected function _execute($sql)
 {
     if (!isset($this->odbc_result)) {
         return odbc_exec($this->conn_id, $sql);
     } elseif ($this->odbc_result === FALSE) {
         return FALSE;
     }
     if (TRUE === ($success = odbc_execute($this->odbc_result, $this->binds))) {
         // For queries that return result sets, return the result_id resource on success
         $this->is_write_type($sql) or $success = $this->odbc_result;
     }
     $this->odbc_result = NULL;
     $this->binds = array();
     return $success;
 }
Example #20
0
 /**
  * Execute the query.
  *
  * @param string $sql an SQL query
  *
  * @return resource
  */
 protected function _execute($sql)
 {
     if (!isset($this->odbc_result)) {
         return odbc_exec($this->conn_id, $sql);
     } elseif ($this->odbc_result === false) {
         return false;
     }
     if (true === ($success = odbc_execute($this->odbc_result, $this->binds))) {
         // For queries that return result sets, return the result_id resource on success
         $this->is_write_type($sql) or $success = $this->odbc_result;
     }
     $this->odbc_result = null;
     $this->binds = [];
     return $success;
 }
<head>
<meta charset="utf-8">
<title>Manage Action</title>
</head>

<body>
<?php 
if (isset($_FILES["paper_file"]) && $_FILES["paper_file"]["error"] > 0) {
    echo "Error: " . $_FILES["paper_ file"]["error"] . "<br />";
} elseif (isset($_FILES["paper_file"])) {
    move_uploaded_file($_FILES["paper_file"]["tmp_name"], "../uploads/UploadImages/" . $_FILES["paper_file"]["name"]);
    //Save the file as the supplied name
}
// create connection
$conn = odbc_connect('VEDB01access1', '', '');
if (!$conn) {
    exit("Connection Failed: " . $conn);
}
// create SQL statement
$sql = "INSERT INTO Employees([FirstName],[LastName],[Title])\n        VALUES('" . $_POST['paper_author'] . "','" . $_FILES["paper_file"]["name"] . "','" . $_POST['paper_title'] . "')";
// prepare SQL statement
$sql_result = odbc_prepare($conn, $sql);
// execute SQL statement and get results
odbc_execute($sql_result);
// free resources
odbc_free_result($sql_result);
?>

</body>
</html>
Example #22
0
        if (!odbc_fetch_row($colnames)) {
            die("false");
        }
        if ($i < $fields_count) {
            $q2 .= odbc_result($colnames, 1) . " = ?,\n";
        } else {
            $q2 .= odbc_result($colnames, 1) . " = ?\n";
        }
    }
    $query = "UPDATE " . $table_name . " SET " . $q2 . " WHERE ROWID = ?;";
}
$statement = odbc_prepare($client->get_connection(), $query);
if ($statement === false) {
    die($query . "\n\n" . get_odbc_error());
}
$items = array();
for ($i = 1; $i <= $fields_count; ++$i) {
    if (isset($_POST["is_null"]) && isset($_POST["is_null"][$i]) && $_POST["is_null"][$i] == true) {
        $items[] = null;
    } else {
        $items[] = $_POST["value"][$i];
    }
}
if ($rowid != null) {
    $items[] = $rowid;
}
$result = odbc_execute($statement, $items);
if ($result === false) {
    die($query . "\n\n" . get_odbc_error());
}
echo "true";
Example #23
0
<meta charset="utf-8">
<link rel="stylesheet" href="estilos/style.css">

<?php 
include "conecta_mysql.inc.php";
$nomeProduto = $_POST["nomeProduto"];
$descricaoproduto = $_POST["descricaoProduto"];
$precProduto = $_POST["precProduto"];
$desconto = $_POST["desconto"];
$idCategoria = $_POST["idCategoria"];
$ativoProduto = $_POST["ativoProduto"];
$idUsuario = $_SESSION['idUsuario'];
$qtdMinEstoque = $_POST["qtdMinEstoque"];
$tmpName = $_FILES['foto']['tmp_name'];
$fp = fopen($tmpName, 'r');
$img = fread($fp, filesize($tmpName));
fclose($fp);
$params = array($nomeProduto, $descricaoproduto, $precProduto, $desconto, $idCategoria, $ativoProduto, $idUsuario, $qtdMinEstoque, $img);
$instrucaoSQL = "insert into produto(nomeProduto, descproduto, precproduto,descontoPromocao, idCategoria,ativoProduto,idUsuario, qtdMinestoque, imagem)  values (?,?,?,?,?,?,?,?,?)";
$rec = odbc_prepare($connect, $instrucaoSQL);
var_dump($rec);
odbc_execute($rec, $params);
?>

Example #24
0
            odbc_free_result($res);
            $res = odbc_prepare($conn, "insert into php_test values(?,?)");
            if ($gif1file != "none") {
                $params[0] = "image1";
                $params[1] = "'{$gif1file}'";
                odbc_execute($res, $params);
            }
            if ($gif2file != "none") {
                $params[0] = "image2";
                $params[1] = "'{$gif2file}'";
                odbc_execute($res, $params);
            }
            if ($gif3file != "none") {
                $params[0] = "image3";
                $params[1] = "'{$gif3file}'";
                odbc_execute($res, $params);
            }
            ?>
 - OK<P>
<A HREF="<?php 
            echo "{$PHP_SELF}?display=y&dbuser={$dbuser}&dsn={$dsn}&dbpwd={$dbpwd}";
            ?>
">Display Images</A>
<?php 
        }
    }
} else {
    ?>
<form action=odbc-t5.php method=post>
<table border=0>
<tr><td>Database: </td><td><input type=text name=dsn></td></tr>
Example #25
0
var_dump($rows);
// fetch
while ($rr = odbc_fetch_array($rh)) {
    var_dump($rr);
}
//////////////////// params
$rh = odbc_prepare($r, "SELECT ATAN(?,?)");
if (!$rh) {
    echo "odbc_prepare failed!\n";
    echo odbc_errormsg();
    echo odbc_close($r);
    exit(1);
}
//var_dump($rh);
echo "resource? " . is_resource($rh) . "\n";
$rv = odbc_execute($rh, array('-2', '2'));
//var_dump($rv);
echo "resource? " . is_resource($rv) . "\n";
if (!$rv) {
    echo "odbc_execute failed!\n";
    echo odbc_errormsg();
    echo odbc_close($r);
    exit(1);
}
$rows = odbc_num_rows($rh);
echo "num rows: {$rows}\n";
var_dump($rows);
// fetch
while ($rr = odbc_fetch_array($rh)) {
    var_dump($rr);
}
Example #26
0
 /**
  * @param string $sql query execute
  * @param array $params not worked
  * @return boolean
  */
 public function execute($sql, $params = [])
 {
     $stmt = odbc_prepare($this->activeConnect, $sql);
     odbc_execute($stmt, $params);
     return true;
 }
 public function query($query, $security = array())
 {
     $this->query = odbc_prepare($this->connect, $query);
     odbc_execute($this->query, $security);
     return $this->query;
 }
Example #28
0
/*---------------------*/
/*Atualizar Categoria*/
if (isset($_POST['idAtCat']) and $_POST['idAtCat'] != null) {
    $idAtCat = $_POST['idAtCat'];
    $nomeAtCat = $_POST['nomeAtCat'];
    $descAtCat = $_POST['descAtCat'];
    if (odbc_exec($connect, "UPDATE Categoria set nomeCategoria='" . $nomeAtCat . "', descCategoria='" . $descAtCat . "' WHERE idCategoria = " . $idAtCat)) {
        echo "<script>alert('Categoria atualizada com sucesso')</script>";
    }
}
/*--------------------*/
/*Atualizar Produto*/
if (isset($_POST['nomeAtProd']) and $_POST['idAtProd'] != null) {
    $idAtProd = $_POST['idAtProd'];
    $nomeAtProduto = $_POST['nomeAtProd'];
    $precoAtProduto = (double) $_POST['precoAtProd'];
    $descontoAtProduto = (double) $_POST['descontoAtProd'];
    $descricaoAtProduto = $_POST['descAtProd'];
    $statusAtProduto = (bool) $_POST['statusAtProduto'];
    $estoqueMinAtProduto = $_POST['estoqueMinAtProd'];
    if (substr($_FILES['imagemAtProd']['type'], 0, 5) == 'image' && $_FILES['imagemAtProd']['error'] == 0 && $_FILES['imagemAtProd']['size'] > 0) {
        $file = fopen($_FILES['imagemAtProd']['tmp_name'], 'rb');
        $fileAtParaDB = fread($file, filesize($_FILES['imagemAtProd']['tmp_name']));
        fclose($file);
    }
    $updateProduto = odbc_prepare($connect, "UPDATE Produto SET nomeProduto = ? ,precProduto = ?,descontoPromocao = ?,descProduto = ?,ativoProduto = ?,qtdMinEstoque = ?,imagem  = ? WHERE idProduto = ? ");
    if (odbc_execute($updateProduto, array($nomeAtProduto, $precoAtProduto, $descontoAtProduto, $descricaoAtProduto, $statusAtProduto, $estoqueMinAtProduto, $fileAtParaDB, $idAtProd))) {
        echo "<script>alert('Produto atualizado com sucesso')</script>";
    }
}
/*---------------------*/
Example #29
0
 function _query($sql, $inputarr = false)
 {
     global $php_errormsg;
     if (isset($php_errormsg)) {
         $php_errormsg = '';
     }
     $this->_error = '';
     if ($inputarr) {
         if (is_array($sql)) {
             $stmtid = $sql[1];
         } else {
             $stmtid = odbc_prepare($this->_connectionID, $sql);
             if ($stmtid == false) {
                 $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
                 return false;
             }
         }
         if (!odbc_execute($stmtid, $inputarr)) {
             //@odbc_free_result($stmtid);
             if ($this->_haserrorfunctions) {
                 $this->_errorMsg = odbc_errormsg();
                 $this->_errorCode = odbc_error();
             }
             return false;
         }
     } else {
         if (is_array($sql)) {
             $stmtid = $sql[1];
             if (!odbc_execute($stmtid)) {
                 //@odbc_free_result($stmtid);
                 if ($this->_haserrorfunctions) {
                     $this->_errorMsg = odbc_errormsg();
                     $this->_errorCode = odbc_error();
                 }
                 return false;
             }
         } else {
             $stmtid = odbc_exec($this->_connectionID, $sql);
         }
     }
     $this->_lastAffectedRows = 0;
     if ($stmtid) {
         if (@odbc_num_fields($stmtid) == 0) {
             $this->_lastAffectedRows = odbc_num_rows($stmtid);
             $stmtid = true;
         } else {
             $this->_lastAffectedRows = 0;
             odbc_binmode($stmtid, $this->binmode);
             odbc_longreadlen($stmtid, $this->maxblobsize);
         }
         if ($this->_haserrorfunctions) {
             $this->_errorMsg = '';
             $this->_errorCode = 0;
         } else {
             $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
         }
     } else {
         if ($this->_haserrorfunctions) {
             $this->_errorMsg = odbc_errormsg();
             $this->_errorCode = odbc_error();
         } else {
             $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
         }
     }
     return $stmtid;
 }
Example #30
0
function deleteOrgAccount($id)
{
    $account = findOrgAccountById($id);
    if ($account['sfdc'] != "") {
        updateSF('org_members', $account['id'], $account['sfdc']);
    }
    $odbc = odbcConnect();
    $stmt = odbc_prepare($odbc, "DELETE FROM org_members WHERE id = ?");
    $rs = odbc_execute($stmt, array($id));
    odbc_close($odbc);
    return $rs;
}