function queryG0($sSQL)
{
    /* dB connection information */
    $server = $GLOBALS['DB_HOST'];
    $user = $GLOBALS['DB_USER'];
    $pass = $GLOBALS['DB_PASSWORD'];
    $db = $GLOBALS['DB_NAME'];
    $dbhandle = mssql_connect($server, $user, $pass) or die("Couldn't connect to SQL Server on {$server}");
    $selected = mssql_select_db($db, $dbhandle) or die("Couldn't open database {$db}");
    $result = mssql_query($sSQL);
    if (!$result) {
        return false;
    } else {
        if (strpos($sSQL, 'INSERT') !== false) {
            $newID = mssql_insert_id();
            return $newID;
        } else {
            return $result;
        }
    }
    mssql_close($con);
}
Пример #2
0
 public function insert_update($table, $data, $condition)
 {
     # Params:
     # 		$table = the name of the table
     # 		$data = field/value pairs to be added/updated
     # 		$condition = example: where id = 99
     if ($table) {
         if ($data) {
             if ($condition) {
                 if ($this->row_exists("select * from {$table} where {$condition}")) {
                     $this->result = mssql_query("update {$table} set {$data} where {$condition}") or $this->setError(mssql_error(), mssql_errno());
                     $this->query = "update {$table} set {$data} where {$condition}";
                     if ($this->result) {
                         $this->affected = intval(mssql_affected_rows());
                         // return the number of rows affected
                         return $this->affected;
                     }
                 } else {
                     $this->result = mssql_query("insert into {$table} set {$data}") or $this->setError(mssql_error(), mssql_errno());
                     $this->query = "insert into {$table} set {$data}";
                     if ($this->result) {
                         $this->insert_id = intval(mssql_insert_id());
                         $this->affected = intval(mssql_affected_rows());
                         // return the number of rows affected
                         return $this->affected;
                     }
                 }
             } else {
                 print "No Condition Specified !!";
             }
         } else {
             print "No Data Specified !!";
         }
     } else {
         print "No Table Specified !!";
     }
 }
Пример #3
0
 function makeNewLine2($table, $A)
 {
     $fields = PMReflector::getAttributesArray($A);
     $values = "";
     #"''";
     $sets = "";
     #"[".$table."ID]";
     for ($i = 0; $i < count($fields); $i++) {
         if ($fields[$i] == $table . "ID") {
             continue;
         }
         $values .= ($values != "" ? ", " : "") . " '" . mssql_real_escape_string($A->{$fields}[$i]) . "'\n";
         $sets .= ($sets != "" ? ", " : "") . "\n[" . $fields[$i] . "]";
     }
     $sql = "INSERT INTO\n [{$table}]\n ({$sets}) VALUES ({$values})";
     $_SESSION["messages"]->addMessage("executing MSSQL: {$sql}");
     mssql_query($sql);
     if (mysql_error() and mysql_errno() == 1054) {
         preg_match("/[a-zA-Z0-9 ]*\\'([a-zA-Z0-9\\.]*)\\'[a-zA-Z ]*\\'([a-zA-Z ]*)\\'.*/", $this->c->error, $regs);
         throw new FieldDoesNotExistException($regs[1], $regs[2]);
     }
     if (mysql_error() and mysql_errno() == 1062) {
         throw new DuplicateEntryException($this->c->error);
     }
     if (mysql_error()) {
         throw new StorageException();
     }
     return mssql_insert_id();
 }