







|
MySQL.RU - Webboard
Вернуться
Вывод с классом (Coffin) 24/05/2004 - 12:38:45
Re: Вывод с классом (haron) 24/05/2004 - 13:06:15
Re: Вывод с классом (haron) 24/05/2004 - 13:07:16
Re: Вывод с классом (Coffin) 24/05/2004 - 13:17:11
Re: Вывод с классом (haron) 24/05/2004 - 13:23:18
Re: Вывод с классом (Coffin) 24/05/2004 - 13:41:22
Re: Вывод с классом (Coffin) 24/05/2004 - 13:58:23
Re: Вывод с классом (haron) 24/05/2004 - 14:23:43
Re: Вывод с классом (Coffin) 24/05/2004 - 14:28:21
Re: Вывод с классом (Coffin) 24/05/2004 - 14:40:52
Re: Вывод с классом (haron) 24/05/2004 - 14:57:43
Re: Вывод с классом (haron) 24/05/2004 - 14:58:55
Re: Вывод с классом (Coffin) 24/05/2004 - 15:02:14
Re: Вывод с классом (haron) 24/05/2004 - 15:10:13
Re: Вывод с классом (Coffin) 24/05/2004 - 15:24:57
Re: Вывод с классом (Coffin) 24/05/2004 - 19:45:29
Re: Вывод с классом (haron) 25/05/2004 - 10:57:15
Re: Вывод с классом (Coffin) 25/05/2004 - 11:52:11
Re: Вывод с классом (haron) 25/05/2004 - 12:51:24
Re: Вывод с классом (Coffin) 25/05/2004 - 13:08:12
Re: Вывод с классом (haron) 25/05/2004 - 14:22:04
> Original message text:
> From: Coffin - 24/05/2004 - 12:38:45
> Subject:Вывод с классом
> -----------------
> Привет :) опять я!
> Имеется все тотже класс :)
> ---------------------------------------------------------------
> class db_driver {
>
> var $obj = array ( "sql_database" => "" ,
> "sql_user" => "root" ,
> "sql_pass" => "" ,
> "sql_host" => "localhost",
> "sql_port" => "" ,
> "persistent" => "0" ,
> "sql_tbl_prefix" => "" ,
> "cached_queries" => array(),
> );
>
> var $query_id = "";
> var $connection_id = "";
> var $query_count = 0;
> var $record_row = array();
> var $return_die = 0;
> var $error = "";
> var $failed = 0;
>
> /**************************************************************************************
> * Соединение с сервером MySQL *
> **************************************************************************************/
>
> function connect() {
>
> if ($this->obj['persistent']) {
> $this->connection_id = mysql_pconnect( $this->obj['sql_host'] ,
> $this->obj['sql_user'] ,
> $this->obj['sql_pass']
> );
> }
> else {
> $this->connection_id = mysql_connect( $this->obj['sql_host'] ,
> $this->obj['sql_user'] ,
> $this->obj['sql_pass']
> );
> }
>
> if ( !mysql_select_db($this->obj['sql_database'], $this->connection_id) ) {
> echo ("ОШИБКА: Невозможно найти базу ".$this->obj['sql_database']);
> }
> }
>
>
>
> /**************************************************************************************
> * Запросы к базе с использованием query *
> **************************************************************************************/
>
> function query($the_query, $bypass=0) {
>
> $this->query_id = mysql_query($the_query, $this->connection_id);
>
> if (! $this->query_id ) {
> $this->fatal_error("mySQL query error: $the_query");
> }
>
> $this->query_count++;
>
> $this->obj['cached_queries'][] = $the_query;
>
> return $this->query_id;
> }
>
>
> // Использование функции fetch_row
> function fetch_row($query_id = "") {
>
> if ($query_id == "")
> {
> $query_id = $this->query_id;
> }
>
> $this->record_row = mysql_fetch_array($query_id, MYSQL_ASSOC);
>
> return $this->record_row;
>
> }
>
>
> // Использование функции get_affected_rows
> function get_affected_rows() {
> return mysql_affected_rows($this->connection_id);
> }
>
>
> // Использование функции get_num_rows
> function get_num_rows() {
> return mysql_num_rows($this->query_id);
> }
>
>
> // Использование функции get_insert_id
> function get_insert_id() {
> return mysql_insert_id($this->connection_id);
> }
>
>
> // Использование функции get_query_cnt
> function get_query_cnt() {
> return $this->query_count;
> }
>
>
> // Освобождение памяти MySQL
> function free_result($query_id="") {
>
> if ($query_id == "") {
> $query_id = $this->query_id;
> }
>
> @mysql_free_result($query_id);
> }
>
>
> // Закрытие соединения с MySQL
> function close_db() {
> return mysql_close($this->connection_id);
> }
>
>
> // Возвращает массив таблиц
> function get_table_names() {
>
> $result = mysql_list_tables($this->obj['sql_database']);
> $num_tables = @mysql_numrows($result);
> for ($i = 0; $i < $num_tables; $i++)
> {
> $tables[] = mysql_tablename($result, $i);
> }
>
> mysql_free_result($result);
>
> return $tables;
> }
>
>
> // Возвращает массив полей
> function get_result_fields($query_id="") {
>
> if ($query_id == "")
> {
> $query_id = $this->query_id;
> }
>
> while ($field = mysql_fetch_field($query_id))
> {
> $Fields[] = $field;
> }
>
> //mysql_free_result($query_id);
>
> return $Fields;
> }
>
>
> //Сообщение об ошибке
> function fatal_error($the_error) {
> global $INFO;
>
> if ($this->return_die == 1)
> {
> $this->error = mysql_error();
> $this->error_no = mysql_errno();
> $this->failed = 1;
> return;
> }
>
> $the_error .= "\n\nmySQL error: ".mysql_error()."\n";
> $the_error .= "mySQL error code: ".$this->error_no."\n";
> $the_error .= "Date: ".date("l dS of F Y h:i:s A");
>
> $out = "<html><head><title>Invision Power Board Database Error</title>
> <style>P,BODY{ font-family:arial,sans-serif; font-size:11px; }</style></head><body>
> <br><br><blockquote><b>There appears to be an error with the {$INFO['board_name']} database.</b><br>
> You can try to refresh the page by clicking <a href=\"javascript:window.location=window.location;\">here</a>, if this
> does not fix the error, you can contact the board administrator by clicking <a href='mailto:{$INFO['email_in']}?subject=SQL+Error'>here</a>
> <br><br><b>Error Returned</b><br>
> <form name='mysql'><textarea rows=\"15\" cols=\"60\">".htmlspecialchars($the_error)."</textarea></form><br>We apologise for any inconvenie | |