コード例 #1
0
ファイル: sqler.php プロジェクト: hunter2814/reason_package
 /**
  * Delete a single row from a database
  * 
  * @access public
  * @param string $table The name of the table from which we are deleting the row
  * @param integer $id The id of the row to delete
  * @param string $primary_key The name of the ID column (defaults to "id")
  * @return mixed (string query if mode is "get_query"; otherwise boolean success)
  */
 function delete_one($table, $id, $primary_key = 'id')
 {
     $q = 'DELETE FROM ' . $table . ' WHERE ' . $primary_key . ' = "' . carl_util_sql_string_escape($id) . '" LIMIT 1';
     if ($this->mode == 'get_query') {
         return $q;
     } else {
         if (mysql_query($q)) {
             return true;
         } else {
             trigger_error('sqler.php :: Unable to delete from ' . $table . ' :: ' . $q, EMERGENCY);
             // if the error level above is EMERGENCY, this script will likely die, but this line is there in case it is not set to die
             return false;
         }
     }
 }
コード例 #2
0
ファイル: getXML.php プロジェクト: hunter2814/reason_package
<?php

/**
 * Provides a web service for the Thor WYSIWYG editor to get the current value of the temporary XML file in the DB
 * @package thor
 */
include_once 'paths.php';
include_once SETTINGS_INC . 'thor_settings.php';
if (!empty($_REQUEST['tmp_id'])) {
    include_once CARL_UTIL_INC . 'db/db.php';
    include_once CARL_UTIL_INC . 'db/db_selector.php';
    connectDB(THOR_FORM_DB_CONN);
    $dbs = new DBSelector();
    $dbs->add_table('thor');
    $dbs->add_field('thor', 'content');
    $dbs->add_relation('thor.id = ' . carl_util_sql_string_escape($_REQUEST['tmp_id']));
    $results = $dbs->run();
    if (count($results) > 0) {
        header('Content-type: text/xml; charset=utf-8');
        echo $results[0]['content'];
    } else {
        $results[0]['content'] = '';
    }
    // 	if ( empty($results[0]['content']) )
    // 		die('<' . '?xml version="1.0" ?' . '><form submit="Submit" reset="Clear" />');
} else {
    die('Please provide a tmp_id.');
}