当前位置: 首页>>代码示例>>PHP>>正文


PHP Database::error方法代码示例

本文整理汇总了PHP中Database::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::error方法的具体用法?PHP Database::error怎么用?PHP Database::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Database的用法示例。


在下文中一共展示了Database::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addBook

 function addBook($query)
 {
     $db = new Database();
     if ($db->error()) {
         echo $db->error();
     } else {
         $db->query($query);
     }
 }
开发者ID:loi219,项目名称:Shared-library,代码行数:9,代码来源:AddBook.php

示例2: Exception

 /**
  * @param $query
  * @param $h Database
  * @param int $resultless
  * @throws Exception
  */
 function __construct($query, &$h, $resultless = 0)
 {
     $this->parent = $h;
     $this->query = $query;
     $this->q = mysql_query($query, $this->parent->dbh);
     if (!$this->q) {
         throw new Exception($this->parent->error());
     }
 }
开发者ID:jmcclenon,项目名称:yourTinyTodo,代码行数:15,代码来源:class.db.mysql.php

示例3: getUserValues

 private function getUserValues($arrayUser)
 {
     $uname = $arrayUser["username"];
     $upass = $arrayUser["password"];
     $email = $arrayUser["email"];
     $time = time();
     $db = new Database();
     $query = "INSERT INTO users(user_name,user_password_hash,user_email,user_registration_datetime) VALUES('{$uname}','{$upass}','{$email}',{$time})";
     $db->query($query);
     if ($db->error()) {
         echo $db->error();
     } else {
         header("Location: /");
     }
 }
开发者ID:loi219,项目名称:Shared-library,代码行数:15,代码来源:createUser.php

示例4: set_new_two_way

 public function set_new_two_way($accountId, $secret)
 {
     /* Controleren of de gebruiker rechten heeft. */
     if (Permission::has('panel_account_two_way')) {
         /* Update query uitvoeren om de secret in te stellen. */
         $update = Database::query("UPDATE customer SET secret = '" . Database::escape($secret) . "' WHERE id = " . Database::escape($accountId));
         /* Kijken of de query is gelukt. */
         if ($update) {
             /* Secret instellen zodat de two-way geactiveerd is in de huidige sessie. */
             $_SESSION['login']['secret'] = true;
         } else {
             /* Query ging fout, geef foutmelding terug. */
             throw new Exception(Database::error());
         }
     }
 }
开发者ID:roaldnefs,项目名称:parkingcity,代码行数:16,代码来源:class.two_way.php

示例5: getRecentPosts

 /**
  * Get recent posts
  *
  * Returns an array of all recent posts, given a certain posts amount.
  *
  * @param int $amount Number of posts to get (defaults to 10).
  * @param int $offset How many posts to skip.
  * @return array Array of {@link Post} instances of all recent posts.
  */
 function getRecentPosts($amount = '%', $offset = 0)
 {
     // default amount from setting
     if ($amount == '%') {
         $amount = $this->getSetting('recent_count');
     }
     // db query
     $sql = 'SELECT `postid`, `time`, `content`, `comments_count` ' . 'FROM `+posts` ' . 'WHERE 1 ' . 'ORDER BY `postid` DESC ' . 'LIMIT ' . ($offset + 0) . ',' . ($amount + 0);
     $q = $this->db->query($sql) or $this->displayError('site->getRecentPosts', $this->db->error());
     $recent = array();
     while ($postdata = $this->db->fetch_assoc($q)) {
         $post = new Post($this);
         $post->fetch_from_array($postdata);
         $recent[] = $post;
     }
     // while
     return $recent;
 }
开发者ID:n0nick,项目名称:n0where,代码行数:27,代码来源:class.site.php

示例6: array

$stmt = "SELECT Title, Contents FROM _posts WHERE Post_ID = ?";
$types = "i";
$array_of_binds = array($post_id);
$result = $db->fetch($stmt, $types, $array_of_binds);
if ($result !== false) {
    $title = $result[0]['Title'];
    $contents = $result[0]['Contents'];
    $something_wrong = false;
}
// Form the site, according to whether one is logged or not
$navbar = "<a class='blog-nav-item' href='index.php'>Home</a>";
$navbar .= "<a class='blog-nav-item' href='addpost.php'>Add Post</a>";
$navbar .= "<a class='blog-nav-item' href='logout.php'>Logout</a>";
// Form main content
if ($something_wrong) {
    $main = $db->error();
} else {
    $main = '
		<div class="col-sm-8 blog-main">
			<form id="form-addpost" class="form-signin" action="editpost_submit.php" method="post">
				<h2 class="form-signin-heading">Edit Post</h2>
				<label for="title" class="sr-only">Title</label>
				<input value=' . $title . ' id="title" class="form-control" name="title" placeholder="Title of the post" maxlength="255" required autofocus>
				<p>The title can only contain a maximum of 255 characters.</p>
				<label for="contents" class="sr-only">Contents</label>
				<textarea id="contents" class="form-control" name="contents" placeholder="Contents of the post" required>' . $contents . '</textarea>
				<p>Github Markdown formatting is supported. Check this <a href="https://guides.github.com/features/mastering-markdown/">link</a> for details.</p>
				<input type="hidden" name="form_token" value="<?php echo $form_token; ?>" />
				<input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
				<button id="form-submit" class="btn btn-lg btn-primary btn-block" type="submit">Edit Post</button>
			</form>
开发者ID:donjar,项目名称:cvwo-assignment-1,代码行数:31,代码来源:editpost.php

示例7: Database

    $message = "An error has occured. Please try again.";
} else {
    $user_id = $_SESSION['user_id'];
    $title = $_POST['title'];
    $contents = $_POST['contents'];
    $db = new Database();
    $stmt = "INSERT INTO _posts (User_ID, Title, Contents) VALUES (?, ?, ?)";
    $types = "sss";
    $array_of_binds = array($user_id, $title, $contents);
    if ($db->query($stmt, $types, $array_of_binds)) {
        $something_wrong = false;
        header('refresh: 3; url = index.php');
        $message = "Post has been successfully added!";
        $message .= "<br /> <a href='index.php'>Click here if you are not redirected.</a>";
    } else {
        $message = $db->error();
    }
}
if ($something_wrong) {
    $message .= "<br /> <a href='addpost.php'>Re-add post</a>";
}
// Form the navbar
$navbar = "<a class='blog-nav-item' href='index.php'>Home</a>";
$navbar .= "<a class='blog-nav-item active' href='addpost.php'>Add Post</a>";
$navbar .= "<a class='blog-nav-item' href='logout.php'>Logout</a>";
?>

<!DOCTYPE html>
<html lang='en'>
	<head>
		<meta charset='utf-8'>
开发者ID:donjar,项目名称:cvwo-assignment-1,代码行数:31,代码来源:addpost_submit.php

示例8: pay_subscription

 public static function pay_subscription($subscription_id, $month, $account_from, $finish_month = false)
 {
     /* Pak de rekeningnummer van CityPark. */
     $account_to = Config::$bank_account;
     /* Haal de maand prijs op en vermenigvuldig dit met $month. */
     $amount = $month * Settings::get('citypark_subscription_month_cost');
     /* Kijken of we de laatste paar dagen moeten berekenen. */
     if ($finish_month) {
         /* Haal totaal aantal dagen op van deze maand. */
         $days_in_month = Date('t');
         /* Bereken het resterende aantal dagen op van deze maand. */
         $days = $days_in_month - Date('j');
         /* Bereken de kosten van 1 dag deze maand. */
         $amount_one_day = $amount / $days_in_month;
         /* Bereken de kosten van de overgebleven dagen. */
         $amount_left = $amount_one_day * $days;
         /* Rond het getal af omhoog, en replace een eventuele komma met een punt. */
         $amount = str_replace(',', '.', round($amount_left, 2, PHP_ROUND_HALF_UP));
     }
     /* Kijken of de transactie is gelukt. */
     if (Bank_api::transfer($amount, $account_from, $account_to)) {
         /* Succesvol overgemaakt, update query maken. */
         $update = Database::query("UPDATE subscription SET last_paid = NOW() WHERE sub_number = " . Database::escape($subscription_id));
         /* Kijken of de query is gelukt. */
         if ($update) {
             /* Customer ID ophalen. */
             $select = Database::query("SELECT customer_id FROM subscription WHERE sub_number = " . Database::escape($subscription_id) . " LIMIT 1");
             /* Kijken of de select query gelukt is. */
             if ($select) {
                 /* Haal de customer ID op. */
                 $cid = $select->fetch_object()->customer_id;
                 /* Probeer onderstaande. */
                 try {
                     /* Nieuw invoice object aanmaken. */
                     $invoice = new Invoice();
                     /* Nieuw factuur aanmaken. */
                     $invoice_id = $invoice->new_invoice($cid);
                     /* Factuur regel aanmaken. */
                     /* $amount bevat in dit geval de prijs wat er betaald is. */
                     $invoice->add_item('Abonnement kosten', 'Van ' . Date('d-m-Y') . ' tot ' . Date('t-m-Y') . '.', '1', $amount);
                     /* Factuur als betaald instellen. */
                     $invoice->set_paid();
                 } catch (Exception $e) {
                     /* Er ging wat fout bij het aanmaken van het factuur. */
                     throw new Exception($e->getMessage());
                 }
                 /* Return een true. */
                 return true;
             } else {
                 /* Foutmelding. */
                 throw new Exception('Er ging wat fout bij het ophalen van uw gegevens voor het factuur.<br />' . Database::error());
             }
         } else {
             /* Query is gefaalt, gooi foutmelding. */
             throw new Exception('Er ging wat fout bij het updaten van de betaling in de database.<br />' . Database::error());
         }
     } else {
         /* Kon niet overmaken. */
         return false;
     }
 }
开发者ID:roaldnefs,项目名称:parkingcity,代码行数:61,代码来源:class.payment.php

示例9: error

 function error($message)
 {
     if ($this->debug) {
         $message = $this->error(pg_last_error($this->link_id));
     }
     parent::error($message);
 }
开发者ID:archcidburnziso,项目名称:opencongress,代码行数:7,代码来源:db.inc.php

示例10: remove_solo

 public static function remove_solo($id, $pid)
 {
     /* Permissie check. */
     if (Permission::has('operator_permission_edit')) {
         /* Escape ID. */
         $id = Database::escape($id);
         /* Escape permission id. */
         $pid = Database::escape($pid);
         /* Select query. */
         $select = Database::query("SELECT id FROM permission_customer_has WHERE customer_id = " . $id . " AND permission_id = " . $pid . " LIMIT 1");
         /* Kijken of query gelukt is. */
         if ($select) {
             /* Kijken of het item bestaat. */
             if ($select->num_rows != 0) {
                 /* Delete query */
                 $delete = Database::query("DELETE FROM permission_customer_has WHERE customer_id = " . $id . " AND permission_id = " . $pid . " LIMIT 1");
                 /* Delete check */
                 if (!$delete) {
                     /* Foutmelding. */
                     throw new Exception('Er ging wat fout bij het verwijderen van de recht.<Br />' . Database::error());
                 }
             } else {
                 /* Bestaat niet. */
                 throw new Exception('De recht die u wenst te verijderen bestaat niet.');
             }
         } else {
             /* Foutmelding. */
             throw new Exception('Er ging wat fout bij de controle.<br />' . Database::error());
         }
     } else {
         /* Geen rechten. */
         throw new Exception('U heeft niet de bevoegdheden om rechten toe te mogen voegen,');
     }
 }
开发者ID:roaldnefs,项目名称:parkingcity,代码行数:34,代码来源:class.permission.php

示例11: import_aicc

    /**
     * Import the aicc object (as a result from the parse_config_files function) into the database structure
     * @param	string	Unique course code
     * @return	bool	Returns -1 on error
     */
    function import_aicc($course_code) {
        $course_id = api_get_course_int_id();

        if ($this->debug > 0) { error_log('New LP - In aicc::import_aicc('.$course_code.')', 0); }
        // Get table names.
        $new_lp = 'lp';
        $new_lp_item = 'lp_item';

        // The previous method wasn't safe to get the database name, so do it manually with the course_code.
        $sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." WHERE code='$course_code'";
        $res = Database::query($sql);
        if (Database::num_rows($res) < 1) { error_log('New LP - Database for '.$course_code.' not found '.__FILE__.' '.__LINE__, 0); return -1; }
        $row = Database::fetch_array($res);

        $new_lp = Database::get_course_table(TABLE_LP_MAIN);
        $new_lp_item = Database::get_course_table(TABLE_LP_ITEM);
        $get_max = "SELECT MAX(display_order) FROM $new_lp WHERE c_id = $course_id";
        $res_max = Database::query($get_max);
        if (Database::num_rows($res_max) < 1) {
            $dsp = 1;
        } else {
            $row = Database::fetch_array($res_max);
            $dsp = $row[0] + 1;
        }

        $this->config_encoding = "ISO-8859-1"; // TODO: We may apply detection for this value, see the function api_detect_encoding().

        $sql = "INSERT INTO $new_lp (c_id, lp_type, name, ref, description, path, force_commit, default_view_mod, default_encoding, js_lib, content_maker,display_order)" .
                "VALUES " .
                "($course_id, 3, '".$this->course_title."', '".$this->course_id."','".$this->course_description."'," .
                "'".$this->subdir."', 0, 'embedded', '".$this->config_encoding."'," .
                "'aicc_api.php','".$this->course_creator."',$dsp)";
        if ($this->debug > 2) { error_log('New LP - In import_aicc(), inserting path: '. $sql, 0); }
        $res = Database::query($sql);
        $lp_id = Database::insert_id();
        $this->lp_id = $lp_id;
        api_item_property_update(api_get_course_info($course_code), TOOL_LEARNPATH, $this->lp_id, 'LearnpathAdded', api_get_user_id());
        api_item_property_update(api_get_course_info($course_code), TOOL_LEARNPATH, $this->lp_id, 'visible', api_get_user_id());

        $previous = 0;
        foreach ($this->aulist as $identifier => $dummy) {
            $oAu =& $this->aulist[$identifier];
            //echo "Item ".$oAu->identifier;
            $field_add = '';
            $value_add = '';
            if (!empty($oAu->masteryscore)) {
                $field_add = 'mastery_score, ';
                $value_add = $oAu->masteryscore.',';
            }
            $title = $oAu->identifier;
            if (is_object($this->deslist[$identifier])) {
                $title = $this->deslist[$identifier]->title;
            }
            $path = $oAu->path;
            //$max_score = $oAu->max_score // TODO: Check if special constraint exists for this item.
            //$min_score = $oAu->min_score // TODO: Check if special constraint exists for this item.
            $parent = 0; // TODO: Deal with the parent.
            $previous = 0;
            $prereq = $oAu->prereq_string;
            //$previous = (!empty($this->au_order_list_new_id[x]) ? $this->au_order_list_new_id[x] : 0); // TODO: Deal with the previous.
            $sql_item = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order) " .
                    "VALUES " .
                    "($course_id, $lp_id, 'au','".$oAu->identifier."','".$title."'," .
                    "'$path',0,100, $value_add" .
                    "$parent, $previous, 0, " .
                    "'$prereq', 0" .
                    ")";
            $res_item = Database::query($sql_item);
            if ($this->debug > 1) { error_log('New LP - In aicc::import_aicc() - inserting item : '.$sql_item.' : '.Database::error(), 0); }
            $item_id = Database::insert_id();
            // Now update previous item to change next_item_id.
            if ($previous != 0) {
                $upd = "UPDATE $new_lp_item SET next_item_id = $item_id WHERE c_id = $course_id AND id = $previous";
                $upd_res = Database::query($upd);
                // Update the previous item id.
            }
            $previous = $item_id;
        }
    }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:84,代码来源:aicc.class.php

示例12: display_database_settings_form


//.........这里部分代码省略.........
        $style = '';
    }

    //Database Name fix replace weird chars
    if ($installType != INSTALL_TYPE_UPDATE) {
        $dbNameForm = str_replace(array('-','*', '$', ' ', '.'), '', $dbNameForm);
        $dbNameForm = replace_dangerous_char($dbNameForm);
    }

    display_database_parameter($installType, get_lang('MainDB'), 'dbNameForm',  $dbNameForm,  '&nbsp;', null, 'id="optional_param1" '.$style);

    //Only for updates we show this options
    if ($installType == INSTALL_TYPE_UPDATE) {
        display_database_parameter($installType, get_lang('StatDB'), 'dbStatsForm', $dbStatsForm, '&nbsp;', null, 'id="optional_param2" '.$style);
        if ($installType == INSTALL_TYPE_UPDATE && in_array($_POST['old_version'], $update_from_version_6)) {
            display_database_parameter($installType, get_lang('ScormDB'), 'dbScormForm', $dbScormForm, '&nbsp;', null, 'id="optional_param3" '.$style);
        }
        display_database_parameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, '&nbsp;', null, 'id="optional_param4" '.$style);
    }
    ?>
    <tr>
        <td></td>
        <td>
            <button type="submit" class="btn" name="step3" value="<?php echo get_lang('CheckDatabaseConnection'); ?>" >
                <?php echo get_lang('CheckDatabaseConnection'); ?></button>
        </td>
    </tr>
    <tr>
        <td>

        <?php

        $dbConnect = test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm, $dbNameForm);

        $database_exists_text = '';

        if (database_exists($dbNameForm)) {
            $database_exists_text = '<div class="warning-message">'.get_lang('ADatabaseWithTheSameNameAlreadyExists').'</div>';
        } else {
            if ($dbConnect == -1) {
                 $database_exists_text = '<div class="warning-message">'.sprintf(get_lang('UserXCantHaveAccessInTheDatabaseX'), $dbUsernameForm, $dbNameForm).'</div>';
            } else {
                 //Try to create the database
                $user_can_create_databases = false;
                $multipleDbCheck = @Database::query("CREATE DATABASE ".mysql_real_escape_string($dbNameForm));
                if ($multipleDbCheck !== false) {
                    $multipleDbCheck = @Database::query("DROP DATABASE IF EXISTS ".mysql_real_escape_string($dbNameForm));
                    $user_can_create_databases = true;
                }

                if ($user_can_create_databases) {
                    $database_exists_text = '<div class="normal-message">'.sprintf(get_lang('DatabaseXWillBeCreated'), $dbNameForm, $dbUsernameForm).'</div>';
                } else {
                    $dbConnect = 0;
                    $database_exists_text = '<div class="warning-message">'.sprintf(get_lang('DatabaseXCantBeCreatedUserXDoestHaveEnoughPermissions'), $dbNameForm, $dbUsernameForm).'</div>';
                }
            }
        }

        if ($dbConnect == 1): ?>
        <td colspan="2">
            <?php echo $database_exists_text ?>
            <div id="db_status" class="confirmation-message">
                Database host: <strong><?php echo Database::get_host_info(); ?></strong><br />
                Database server version: <strong><?php echo Database::get_server_info(); ?></strong><br />
                Database client version: <strong><?php echo Database::get_client_info(); ?></strong><br />
                Database protocol version: <strong><?php echo Database::get_proto_info(); ?></strong>
                <div style="clear:both;"></div>
            </div>
        </td>
        <?php else: ?>
        <td colspan="2">
            <?php echo $database_exists_text ?>
            <div id="db_status" style="float:left;" class="error-message">
                <div style="float:left;">
                    <strong><?php echo get_lang('FailedConectionDatabase'); ?></strong><br />
                    <strong>Database error: <?php echo Database::errno(); ?></strong><br />
                    <?php echo Database::error().'<br />'; ?>
                </div>
            </div>
        </td>
        <?php endif; ?>
    </tr>
    <tr>
      <td>
          <button type="submit" name="step2" class="back" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button>
      </td>
      <td>&nbsp;</td>
      <td align="right">
          <input type="hidden" name="is_executable" id="is_executable" value="-" />
           <?php if ($dbConnect == 1) { ?>
            <button type="submit"  class="btn next" name="step4" value="<?php echo get_lang('Next'); ?> &gt;" /><?php echo get_lang('Next'); ?></button>
          <?php } else { ?>
            <button disabled="disabled" type="submit" class="btn next disabled" name="step4" value="<?php echo get_lang('Next'); ?> &gt;" /><?php echo get_lang('Next'); ?></button>
          <?php } ?>
      </td>
    </tr>
    </table>
    <?php
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:install.lib.php

示例13: operator_show

 public static function operator_show($id)
 {
     /* Permission check. */
     if (Permission::has('operator_subscription_list')) {
         /* ID Escapen. */
         $id = Database::escape($id);
         /* Select query. */
         $select = Database::query("SELECT c.username, c.email, c.secret, c.active, UNIX_TIMESTAMP(c.register_date) AS register_date, ci.* FROM customer AS c INNER JOIN customer_info AS ci ON ci.customer_id = c.id WHERE c.id = " . $id);
         /* Query controle. */
         if ($select) {
             /* Kijken of er een result is. */
             if ($select->num_rows != 0) {
                 /* Return het object. */
                 return $select->fetch_object();
             } else {
                 /* Geen rows. */
                 throw new Exception('De geselecteerde abonnee bestaat niet (meer).');
             }
         } else {
             /* Foutmelding. */
             throw new Exception('Er ging wat fout bij het ophalen van de abonnee gegevens.' . Database::error());
         }
     } else {
         /* Geen rechten. */
         throw new Exception('U heeft geen rechten om alle abonnees te mogen bekijken.');
     }
 }
开发者ID:roaldnefs,项目名称:parkingcity,代码行数:27,代码来源:class.subscription.php

示例14: WSCreateUserPasswordCrypted

function WSCreateUserPasswordCrypted($params)
{
    global $_user, $_configuration, $debug;
    if ($debug) {
        error_log('WSCreateUserPasswordCrypted');
    }
    if ($debug) {
        error_log(print_r($params, 1));
    }
    if (!WSHelperVerifyKey($params)) {
        return return_error(WS_ERROR_SECRET_KEY);
    }
    // Database table definition.
    $table_user = Database::get_main_table(TABLE_MAIN_USER);
    $result = array();
    $orig_user_id_value = array();
    $password = $params['password'];
    $encrypt_method = $params['encrypt_method'];
    $firstName = $params['firstname'];
    $lastName = $params['lastname'];
    $status = $params['status'];
    $email = $params['email'];
    $loginName = $params['loginname'];
    $official_code = $params['official_code'];
    $language = '';
    $phone = '';
    $picture_uri = '';
    $auth_source = PLATFORM_AUTH_SOURCE;
    $expiration_date = '0000-00-00 00:00:00';
    $active = 1;
    $hr_dept_id = 0;
    $extra = null;
    $original_user_id_name = $params['original_user_id_name'];
    $original_user_id_value = $params['original_user_id_value'];
    $orig_user_id_value[] = $params['original_user_id_value'];
    $extra_list = $params['extra'];
    if (!empty($_configuration['password_encryption'])) {
        if ($_configuration['password_encryption'] === $encrypt_method) {
            if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
                $msg = "Encryption {$encrypt_method} is invalid";
                if ($debug) {
                    error_log($msg);
                }
                return $msg;
            } else {
                if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) {
                    $msg = "Encryption {$encrypt_method} is invalid";
                    if ($debug) {
                        error_log($msg);
                    }
                    return $msg;
                }
            }
        } else {
            $msg = "This encryption {$encrypt_method} is not configured";
            if ($debug) {
                error_log($msg);
            }
            return $msg;
        }
    } else {
        $msg = 'The chamilo setting $_configuration["password_encryption"] is not configured';
        if ($debug) {
            error_log($msg);
        }
        return $msg;
    }
    if (!empty($params['language'])) {
        $language = $params['language'];
    }
    if (!empty($params['phone'])) {
        $phone = $params['phone'];
    }
    if (!empty($params['expiration_date'])) {
        $expiration_date = $params['expiration_date'];
    }
    // Check whether x_user_id exists into user_field_values table.
    $user_id = UserManager::get_user_id_from_original_id($original_user_id_value, $original_user_id_name);
    if ($debug) {
        error_log('Ready to create user');
    }
    if ($user_id > 0) {
        if ($debug) {
            error_log('User found with id: ' . $user_id);
        }
        // Check whether user is not active
        //@todo why this condition exists??
        $sql = "SELECT user_id FROM {$table_user} WHERE user_id ='" . $user_id . "' AND active= '0' ";
        $resu = Database::query($sql);
        $r_check_user = Database::fetch_row($resu);
        $count_check_user = Database::num_rows($resu);
        if ($count_check_user > 0) {
            if ($debug) {
                error_log('User id: ' . $user_id . ' exists and is NOT active. Updating user and setting setting active = 1');
            }
            $sql = "UPDATE {$table_user} SET\n                    lastname='" . Database::escape_string($lastName) . "',\n                    firstname='" . Database::escape_string($firstName) . "',\n                    username='" . Database::escape_string($loginName) . "',";
            if (!is_null($auth_source)) {
                $sql .= " auth_source='" . Database::escape_string($auth_source) . "',";
            }
            $sql .= "\n                    password='" . Database::escape_string($password) . "',\n                    email='" . Database::escape_string($email) . "',\n                    status='" . Database::escape_string($status) . "',\n                    official_code='" . Database::escape_string($official_code) . "',\n                    phone='" . Database::escape_string($phone) . "',\n                    expiration_date='" . Database::escape_string($expiration_date) . "',\n                    active='1',\n                    hr_dept_id=" . intval($hr_dept_id);
//.........这里部分代码省略.........
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:101,代码来源:registration.soap.php

示例15: get_invoice_data

 public static function get_invoice_data()
 {
     /* Permission check. */
     if (Permission::has('operator_chart_invoice')) {
         /* Selecteer alle invoice items vanaf nu en 1 jaar terug. */
         $select = Database::query("SELECT UNIX_TIMESTAMP(i.create_date) AS create_date, i.type_customer, (SELECT SUM(price) FROM invoice_data WHERE invoice_id = i.id AND price IS NOT NULL) AS price FROM invoice AS i WHERE create_date >= DATE_SUB(NOW(), INTERVAL 1 YEAR)");
         /* Kijken of query is gelukt. */
         if ($select) {
             /* Kijken of er minimaal één result is. */
             if ($select->num_rows != 0) {
                 /* Return array .*/
                 $return = array();
                 /* Database array aanmaken. */
                 $db_array = array();
                 /* Doorloop alle items uit DB. */
                 while ($obj = $select->fetch_object()) {
                     /* Sla object in array op. */
                     $db_array[] = $obj;
                 }
                 /* Tel aantal items in db_array. */
                 $db_array_count = count($db_array);
                 /* Loop 13x (12 maanden in 1 jaar, plus 1 erbij om het huidige maand te bekijken). */
                 for ($i = 12; $i > -1; $i--) {
                     /* d-m-Y van huidige maand uit de loop. */
                     $time = Date('m-Y', strtotime("-" . $i . " month"));
                     /* Sla time op in de return array, en maak er een array van. */
                     $return[$time] = array('ad-hoc' => 0, 'subscription' => 0);
                     /* Doorloop de database array. */
                     for ($j = 0; $j < $db_array_count; $j++) {
                         /* Obj var aanmaken. */
                         $obj = $db_array[$j];
                         /* Kijken of het huidige factuur bij de huidige datum hoort. */
                         if (Date('m-Y', $obj->create_date) == $time) {
                             /* Kijken wat het type customer is. */
                             if ($obj->type_customer == 'subscription') {
                                 /* Voeg het prijs toe aan de array. */
                                 $return[$time]['subscription'] = $return[$time]['subscription'] + $obj->price;
                             } else {
                                 /* Voeg het prijs toe aan de array. */
                                 $return[$time]['ad-hoc'] = $return[$time]['ad-hoc'] + $obj->price;
                             }
                         }
                     }
                 }
                 /* Geef de array terug. */
                 return $return;
             }
         } else {
             /* Foutmelding. */
             throw new Exception('Er ging wat fout bij het opzoeken van de facturen het laatste jaar.<br />' . Database::error());
         }
     } else {
         /* Geen permissies. */
         throw new Exception('U heeft geen rechten om deze chart te mogen zien.');
     }
 }
开发者ID:roaldnefs,项目名称:parkingcity,代码行数:56,代码来源:class.chart.php


注:本文中的Database::error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。