Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Класс для работы с базой, Обсуждаем, делаем... 
V
    Опции темы
Wowa
  Дата 17.6.2005, 14:35 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
Group Icon


Профиль
Группа: Админ
Сообщений: 15017
Регистрация: 14.9.2000
Где: Винград

Репутация: нет
Всего: 290



В принципе, можно написать свой класс, но есть уже готовый и довольно хороший. А писать самому - будет примерно тоже самое. Давайте этот класс возьмем за основку для работы с базой.
Код

<?php
//****************************************************************************
// phpDatabase 2.1
//****************************************************************************
//      Author: Maxim Poltarak  <maxx at e dash taller dot net>
//    Category: Databases
//****************************************************************************
// The lib is FREEWARE. This means you may use it anywhere you want, you may 
// do anything with it. The Author mentioned above is NOT responsible for any 
// consequences of using this library. 
// If you don't agree with this, you MAY NOT use the lib!
//****************************************************************************
// All improvings, feature requests, bug reports, etc. are gladly accepted.
//****************************************************************************
// Note: For best viewing of the code Tab size 4 is recommended
//****************************************************************************
class CDatabase {
    var $link;
    var $db;
    var $host, $user, $pass;

    function CDatabase($db, $host="localhost", $user="", $pass="") {
        $this->db = $db; $this->host = $host; $this->user = $user; $this->pass = $pass;
        if($this->link = mysql_connect($host,$user,$pass))
            return mysql_select_db($db, $this->link);
            else return 0;
    }

    function query($sql) {    
        if(!$this->link) return 0;
        return mysql_query($sql, $this->link);
    }

    function affected_rows() {
        return mysql_affected_rows($this->link);
    }

    function num_rows($q) {
        return mysql_num_rows($q);
    }

    function fetch_array($q, $result_type=MYSQL_ASSOC) {
        return mysql_fetch_array($q, $result_type);
    }

    function fetch_object($q) {
        return mysql_fetch_object($q);
    }

    function data_seek($q, $n) {
        return mysql_data_seek($q, $n);
    }

    function free_result($q) {
        return mysql_free_result($q);
    }

    function insert_id() {
        return mysql_insert_id($this->link);
    }

    function error() {
        return mysql_error($this->link);
    }

    function error_die($msg='') {
        die(((empty($msg))?'':$msg.': ').$this->error());
    }

    function sql2var($sql) {
        if((empty($sql)) || (!($query = $this->query($sql)))) return false;
        if($this->num_rows($query) < 1) return false;
        return $this->result2var($query);
    }

    function result2var($q) {
        if(!($Data = $this->fetch_array($q))) return false;
        $this->free_result($q);
        foreach($Data as $k=>$v) $GLOBALS[$k] = $v;
        return true;
    }

    function sql2array($sql, $keyField='') {
        if((empty($sql)) || (!($query = $this->query($sql)))) return false;
        if($this->num_rows($query) < 1) return false;
        return $this->result2array($query, $keyField);
    }

    function result2array($q, $keyField='') {
        $Result = array();
        while($Data = $this->fetch_array($q))
            if(empty($keyField)) $Result[] = $Data;
            else $Result[$Data[$keyField]] = $Data;
        $this->free_result($q);
        return $Result;
    }

    function list_tables() {
        return mysql_list_tables($this->db, $this->link);
    }

    function list_fields($table_name) {
        return mysql_list_fields($this->db, $table_name, $this->link);
    }
    function db_row($query) {
      $r=mysql_query($query);
        //  if (!$r) die(mysql_error());
       if (!$r) die("MySQL error ".mysql_errno().": ".mysql_error()."\n<br>When executing:<br>\n$query\n<br>");
       if (!mysql_num_rows($r)) return array();
        //  if (!mysql_num_rows($r)) return 0;
       return mysql_fetch_array($r);
    }
};

?>


Или будут еще какие-либо предложения у кого-то?
PM WWW   Вверх
Mal Hack
Дата 17.6.2005, 17:49 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Мудрый...
****


Профиль
Группа: Участник Клуба
Сообщений: 9926
Регистрация: 15.2.2004

Репутация: нет
Всего: 261



Код
<?php

 if( ! defined( "KERNEL" ) )
  {  exit( "System error." );  }

 class SQL_Driver extends SQL_Global
  {
   var $Connected              = TRUE;
   var $Handle                 = NULL;
   var $Result                 = NULL;
   var $Query_Count            = 0;
   var $Query                  = array();
   var $Query_Error_Text       = array();
   var $Query_Error_Number     = 0;
   var $Count_Rows             = array();
   var $Count_Cols             = array();
   var $DataObj                = array( array() );
   var $Fields                 = array( array() );
   var $Query_Insert_Id        = array();

   function SQL_Driver( $h , $p , $u , $ps , $b )
    {
     $h              = ( ! empty( $p ) ) ? $h . ":" . $p : $h ;
     $this -> Handle = @ mysql_connect( $h , $u , $ps );

     if( $this -> Handle )
      {  $this -> Connected = TRUE ;  }

     if( @ mysql_select_db( $b , $this -> Handle ) == TRUE )
      {  $this -> Connected = TRUE ;  }
    }

   function __destruct()
    {  @ mysql_close( $this -> Handle );  }

   function SQl_Query( $query )
    {
     $this -> Query_Count++;

   #  print
     $this -> Query[ $this -> Query_Count ] = $query;
   #  print "<br>";
     $this -> Result = @ mysql_query( $this -> Query[ $this -> Query_Count ] , $this -> Handle );

     preg_match( "/^\s*((create\s*[^\s]+)|(show\s*[^\s]+)|([^\s]+))/i" , $this -> Query[ $this -> Query_Count ] ,  $matches );
     $this -> Query_Type[ $this -> Query_Count ] = strtoupper( $matches[1] );

     print $this -> Query_Error_Text[ $this -> Query_Count ] = mysql_error( $this -> Handle );
     $this -> Query_Error_Number = mysql_errno( $this -> Handle );

     if( $this -> Query_Error_Number != 0 )
      {  return FALSE;  }

     switch( $this -> Query_Type[ $this -> Query_Count ] )
      {
       case "SELECT":           $ret = $this -> SQl_Get_DataObj();
                                mysql_free_result( $this -> Result );
            break;
       case "INSERT":           $this -> Query_Insert_Id[ $this -> Query_Count ] = @ mysql_insert_id( $this -> Result );
                                $ret = TRUE;
            break;
       default:                 $ret = TRUE;
            break;
      }

     return $ret;
    }

   function SQl_Get_DataObj()
    {
     $this -> Count_Rows[ $this -> Query_Count ] = mysql_num_rows( $this -> Result );
     $this -> Count_Cols[ $this -> Query_Count ] = mysql_num_fields( $this -> Result );
     $this -> SQL_Get_fields_name();

     if ( $this -> Count_Rows[ $this -> Query_Count ] <= 0 )
      {  return FALSE;  }

     $i = 0;
     while( $this -> DataObj[ $this -> Query_Count ][$i] = mysql_fetch_object( $this -> Result ) )
      {  $i++;  }

     return TRUE;
    }

   function SQL_Get_fields_name()
    {
     for( $i = 0 ; $i < $this -> Count_Cols[ $this -> Query_Count ] ; $i++ )
      {  $this -> Fields[ $this -> Query_Count ][$i] = mysql_field_name( $this -> Result , $i );  }
    }
  }

?>

PM ICQ   Вверх
Irokez
Дата 17.6.2005, 19:24 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


индеец
***


Профиль
Группа: Участник Клуба
Сообщений: 1180
Регистрация: 20.10.2004

Репутация: нет
Всего: 53



для работы с базой:
Код

<?php
/*
    db.class.php - contains ICM_DBase class description
*/

$GLOBALS['DB']=xparse_ini_file("{$GLOBALS['PTH']['conf']}dbase.conf", false);   //database configs

/*
    class ICM_DB - class to work with database
    implements work with mysql database
*/
class ICM_DB
{
    var $_link;     //link to mysql database
    var $_host;     //database host
    var $_login;    //database login
    var $_pass;     //database password
    var $_name;     //database name
    /* methods:
    bool ICM_DB()
    mixed exeQuery(string query)
    mixed getResult(string query)
    array getTables()
    array getFields(string table_name)
    int lastID()
    */

/*
    constructor, connects to database
    receives database attributes
    returnes true if connected
*/
    function ICM_DB()
    {
        $this->_host=$GLOBALS['DB']['host'];
        $this->_login=$GLOBALS['DB']['login'];
        $this->_pass=$GLOBALS['DB']['pass'];
        $this->_name=$GLOBALS['DB']['name'];
        $this->_link=mysql_connect($this->_host,$this->_login,$this->_pass);
        return mysql_select_db($this->_name,$this->_link);
    }

/*
    executes mysql query
    receives given query
    returnes mysql result
*/
    function exeQuery($query)
    {
        if($GLOBALS['DB']['show_error'])
            $result=mysql_unbuffered_query($query,$this->_link)
                or die("Error ".mysql_errno().': '.mysql_error()."<br>Query: ".nl2br($query));
        else
            $result=mysql_query($query,$this->_link);
        return $result;
    }

/*
    executes mysql query and returnes result
    receives string
    returnes result
*/
    function getResult($query)
    {
        $result=$this->exeQuery($query);
        $data=mysql_fetch_array($result);
        return $data[0];
    }

/*
    gets list of tables in current database
    receives nothing
    returnes names of tables
*/
    function getTables()
    {
        $tables_names=array();
        $tables=mysql_list_tables($this->_name, $this->_link);
        $property_name='Tables_in_'.$this->_name;
        while($table=mysql_fetch_object($tables))
            array_push($tables_names, $table->$property_name);
        return $tables_names;
    }

/*
    gets fields' names of a given table
    receives table name
    returnes fields names
*/
    function getFields($table)
    {
        $fields=mysql_list_fields($this->_name, $table, $this->_link);
        $fields_num=mysql_num_fields($fields);
        for($i=0; $i<$fields_num; $i++)
            $fields_names[$i+1]=mysql_field_name($fields, $i);
        return $fields_names;
    }

/*
    gets id of last inserted row
    receives nothing
    return ID
*/
    function lastID()
    {
        return mysql_insert_id($this->_link);
    }
}
?>


для работы с таблицей:
Код

<?php
/*
    table.class.php - contains ICM_Table class description
*/

$GLOBALS['TBL']=xparse_ini_file("{$GLOBALS['PTH']['conf']}tables.conf", true);  //tables' configs
require_once "db.class.php";    //ICM_DB description

/*
    class ICM_Table - class to work with database tables
*/
class ICM_Table
{
    var $db;       //database object
    var $_name;    //table name
    var $_trans;   //postfix for tables with translatable data
    var $_item;    //key-item field name
    var $_lang;    //language field name
    /* methods:
    bool ICM_Table(array table_attrib)
    int insert(array data)
    bool update(int id, array data)
    bool delete(int id)
    array select(int id)
    array all([...])
    array selectAll([...])
    mixed getValue(int id, string field);
    mixed getTValue(int id, int lang, string field);
    */

/*
    constructor
    receives table attributes
    returnes true
*/
    function ICM_Table($table_name, $trans_postfix, $keyitem, $langfield)
    {
        $this->db=new ICM_DB;
        $this->_name=$table_name;
        $this->_trans=$trans_postfix;
        $this->_item=$keyitem;
        $this->_lang=$langfield;
        return true;
    }

/*
    inserts data in table
    receives data to insert
    returnes inserted ID
*/
    function insert($data)
    {

        /*
            first parse data, get fields and values
            if $data[$field] is an array it means that it's translatable data
            where $data[$field][$lang] - is it's value and $lang - language ID
        */
        foreach($data as $field => $value)
            if(!is_array($value))
            {
                if(isset($fields)) $fields.=", `$field`";
                else $fields="`$field`";
                if(isset($values)) $values.=" ,'$value'";
                else $values="'$value'";
            }
            else
                foreach($value as $lang => $value_trans)
                {
                    if(isset($fields_trans[$lang])) $fields_trans[$lang].=", `$field`";
                    else $fields_trans[$lang]="`$field`";
                    if(isset($values_trans[$lang])) $values_trans[$lang].=", '$value_trans'";
                    else $values_trans[$lang]="'$value_trans'";
                }

        /*
            insert data
        */
        $query="insert into `{$this->_name}` ($fields) values ($values)";
        $result=$this->db->exeQuery($query);
        $last_id=$this->db->lastID();

        /*
            if there is translatable data then insert it
        */
        if(isset($fields_trans))
            foreach($fields_trans as $lang => $fields)
            {
                $values=$values_trans[$lang];
                $query="insert into `{$this->_name}{$this->_trans}` (`{$this->_item}`, `{$this->_lang}` ,$fields)
                        values ('$last_id', '$lang', $values)";
                $result=$this->db->exeQuery($query);
            }

        return $last_id;
    }

/*
    updates data in table
    receives ID of a row, data to update
    returnes true if succeed
*/
    function update($id, $data)
    {

        /*
            first check if there is row with such ID
            if not we insert data instead of updating it
        */
        $query="select count(*) from `{$this->_name}` where `id`='$id'";
        $num=$this->db->getResult($query);
        if($num)
        {
            /*
                like in insert(), we parse data first
            */
            foreach($data as $field => $value)
                if(!is_array($value))
                    if(isset($sets)) $sets.=", `$field`='$value'";
                    else $sets="`$field`='$value'";
                else
                    foreach($value as $lang => $value_trans)
                    {
                        $query="select count(*) from `{$this->_name}{$this->_trans}`
                                where `{$this->_item}`='$id' and `{$this->_lang}`='$lang'";
                        $num=$this->db->getResult($query);
                        if($num)
                            if(isset($sets_trans[$lang])) $sets_trans[$lang].=", `$field`='$value_trans'";
                            else $sets_trans[$lang]="`$field`='$value_trans'";
                        else
                            $query="insert into `{$this->_name}{$this->_trans}`
                                    (`{$this->_item}`, `{$this->_lang}`, $field)
                                    values ('$id', '$lang', '$value_trans')";
                            $this->db->exeQuery($query);
                    }

            /*
                update data
            */
            $query="update `{$this->_name}` set $sets where `id`='$id'";
            $result=$this->db->exeQuery($query);

            /*
                update translatable data
            */
            if(isset($sets_trans))
                foreach($sets_trans as $lang => $set)
                {
                    $query="update `{$this->_name}{$this->_trans}`
                            set $set
                            where `{$this->_item}`='$id' and `{$this->_lang}`='$lang'";
                    $result=$this->db->exeQuery($query);
                }
        }
        else
        {
            $data['id']=$id;
            $result=$this->insert($data);
        }
        return (bool)$result;
    }

/*
    deletes data from table
    receives ID of a row to delete
    returnes true if succeed
*/
    function delete($id)
    {

        /*
            delete data
        */
        $query="delete from `{$this->_name}` where `id`='$id'";
        $result=$this->db->exeQuery($query);

        /*
            delete translatable data if exists
        */
        if(in_array($this->_name.$this->_trans, $this->db->getTables()))
        {
            $query="delete from `{$this->_name}{$this->_trans}` where `{$this->_item}`='$id'";
            $result=$this->db->exeQuery($query);
        }

        return (bool)$result;
    }

/*
    gets row with given ID
    receives row ID
    returnes associative array of data or empty array if row does not exists
*/
    function select($id)
    {
        $data=array();

        /*
            check whether row with given ID exists
        */
        $query="select count(*) from `{$this->_name}` where `id`='$id'";
        $num=$this->db->getResult($query);
        if($num)
        {
            /*
                get data
            */
            $query="select * from `{$this->_name}` where `id`='$id'";
            $result=$this->db->exeQuery($query);
            $data=mysql_fetch_assoc($result);
            mysql_free_result($result);

            /*
                get translatable data if exists
            */
            if(in_array($this->_name.$this->_trans, $this->db->getTables()))
            {
                /*
                    list of system fields
                    we do not need to select from table with translatable data
                */
                $sys_fields=array('id', $this->_item, $this->_lang);

                $query="select * from `{$this->_name}{$this->_trans}` where `{$this->_item}`='$id'";
                $result=$this->db->exeQuery($query);
                while($tdata=mysql_fetch_assoc($result))
                    foreach($tdata as $field => $value)
                        if(!in_array($field, $sys_fields))
                            $data[$field][$tdata[$this->_lang]]=$value;
            }
        }

        return $data;
    }

/*
    gets all data from table
    receives:
        nothing
        or: where
        or: start, limit
        or: order, [dir]
        or: start, limit, order, [dir], [where]
    returnes array of IDs
*/
    function all()
    {

        /*
            get arguments and parse them
        */
        $args=func_get_args();
        $args_num=count($args);

        if($args_num==1)
        {
            if(is_string($args[0])) $where=$args[0];
            elseif(is_numeric($args[0])) $limit=$args[0];
        }
        elseif($args_num==2)
        {
            if(is_numeric($args[0]) && is_numeric($args[1]))
            {
                $start=$args[0];
                $limit=$args[1];
            }
            elseif(is_string($args[0]) && is_string($args[1]))
            {
                $order=$args[0];
                $dir=$args[1];
            }
        }
        elseif($args_num>=3)
        {
            if(is_numeric($args[0])) $start=$args[0];
            if(is_numeric($args[1])) $limit=$args[1];
            if(is_string($args[2])) $order=$args[2];
            if(isset($args[3])) if(is_string($args[3])) $dir=$args[3];
            if(isset($args[4])) if(is_string($args[4])) $where=$args[4];
        }

        $row=array();
        $order4query='';
        $limit4query='';
        $where4query='';

        if(isset($order))
        {
            if(in_array($this->_name.$this->_trans, $this->db->getTables()))
                $all_fields=array_merge($this->db->getFields($this->_name), $this->db->getFields($this->_name.$this->_trans));
            else
                $all_fields=$this->db->getFields($this->_name);
            if(in_array($order, $all_fields))
            {
                $order4query="order by `$order`";
                if(isset($dir))
                    if(in_array($dir, array('desc', 'asc'))) $order4query.=" $dir";
            }
        }
        if(isset($limit))
        {
            if(isset($start)) $limit4query="limit $start, $limit";
            else $limit4query="limit $limit";
        }
        if(isset($where)) $where4query=" $where";

        if(in_array($this->_name.$this->_trans, $this->db->getTables()))
            $query="select tbl.id from `{$this->_name}` as tbl, `{$this->_name}{$this->_trans}` as tbl_t
                    where tbl.id=tbl_t.{$this->_item} $where4query $order4query $limit4query";
        else
            $query="select id from `{$this->_name}`
                    where 1 $where4query $order4query $limit4query";

        $result=$this->db->exeQuery($query);
        while($data=mysql_fetch_assoc($result))
            if(!in_array($data['id'], $row)) array_push($row, $data['id']);

        return $row;
    }

/*
    selects all data from table
    gets all data from table
    receives:
        nothing
        or: where
        or: start, limit
        or: order, [dir]
        or: start, limit, order, [dir], [where]
    returnes associative array of data
*/
    function selectAll()
    {
        $data=array();
        $args=func_get_args();
        $rows=call_user_func_array(array(&$this, 'all'), $args);
        foreach($rows as $id)
            array_push($data, $this->select($id));
        return $data;
    }

/*
    gets field value of row with given ID, if such exists
    receives row ID and field name
    returnes field value or false if row doesn't exists
*/
    function getValue($id, $field)
    {
        $value=false;

        /*
            check whether row with given ID exists
        */
        $query="select count(*) from `{$this->_name}` where id='$id'";
        $num=$this->db->getResult($query);
        if($num)
        {
            /*
                check whether given field exists
            */
            if(in_array($field, $this->db->getFields($this->_name)))
            {
                $query="select `$field` from `{$this->_name}` where `id`='$id'";
                $value=$this->db->getResult($query);
            }
        }

        return $value;
    }

/*
    gets value of translatable field
    receives row ID, language ID, field name
    returnes field value or false if does not exists
*/
    function getTValue($id, $lang, $field)
    {
        $value=false;

        /*
            check whether row with given ID and language ID exists
        */
        $query="select count(*) from `{$this->_name}{$this->_trans}`
                where `{$this->_item}`='$id' and `{$this->_lang}`='$lang'";
        $num=$this->db->getResult($query);
        if($num)
        {
            /*
                check whether given field exists
            */
            if(in_array($field, $this->db->getFields($this->_name.$this->_trans)))
            {
                $query="select `$field` from `{$this->_name}{$this->_trans}`
                        where `{$this->_item}`='$id' and `{$this->_lang}`='$lang'";
                $value=$this->db->getResult($query);
            }
        }

        return $value;
    }

}
?>

PM   Вверх
Рыжий
Дата 17.6.2005, 20:49 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Помешанный
***


Профиль
Группа: Завсегдатай
Сообщений: 1423
Регистрация: 19.9.2004

Репутация: нет
Всего: 20



хм, в книге ПРоффесиональное PHP программирование давалось class db - простой API для работы с базой данных, чем он плох?? smile
PM MAIL ICQ   Вверх
Irokez
Дата 17.6.2005, 20:53 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


индеец
***


Профиль
Группа: Участник Клуба
Сообщений: 1180
Регистрация: 20.10.2004

Репутация: нет
Всего: 53



Цитата(PHP @ 17.6.2005, 20:49)
чем он плох??

тем что мы его не видели smile
PM   Вверх
Рыжий
Дата 17.6.2005, 22:49 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Помешанный
***


Профиль
Группа: Завсегдатай
Сообщений: 1423
Регистрация: 19.9.2004

Репутация: нет
Всего: 20



Я вообщето его с книги наьирал, поэтому могут быть синтаксические ошибки smile Но помоему сам скрипт можно скачать с wrox.com ну ладно вот код:

Код

<?php<?php
class db
{
        /* параметры соединения*/
        var $host = '';
        var $user = '';
        var $password = '';
        var $database = '';
        var $persistent=false;

        /*Дескриптор соединения с Базой Данных*/
        var $conn = NULL;

        /*Результат запроса */
        var $result=false;

            function db($host,$user,$password,$database,$persistent=false)
                 {
                  $this->host = $host;
                  $this->user = $user;
                  $this->password = $password;
                  $this->database = $database;
                  $this->persistent = $persistent;
                 }
            function open()
                 {
                  /*Выбрать соответствующую функцию соединения*/
                  if ($this->persistent){
                          $func = 'mysql_pconnect';
                          }
                          else
                          {
                           $func = 'mysql_connect';
                          }
                  /*соединиться с сервером MySQL*/
                  $this->conn = $func($this->host,$this->user,$this->password);
                  if(!$$this->conn)
                       {
                       return false;
                       }
                  /*Выбрать запрошенную базу данных*/
                  if (@!mysql_select_db($this->database,$this->conn))
                       {
                        return false;
                       }
                       return true;
                 }

             function close()
                  {
                   return(@mysql_close($this->conn));
                  }

             function error()
                  {
                   return (mysql_error());
                  }

             function query($sql)
                  {
                   $this->result = @mysql_query($sql,$this->conn);
                   return($this->result!=false);
                  }

             function affectedrows()
                  {
                   return(@mysql_affected_rows($this->conn));
                  }

             function numrows()
                  {
                   return (@mysql_num_rows($this->result));
                  }

             function fetchobject()
                  {
                   return (@mysql_fetch_object($this->result,MYSQL_ASSOC));
                  }

             function fetcharray()
                  {
                   return(@mysql_fetch_array($this->result,MYSQL_NUM));
                  }

             function fetchassoc()
                  {
                   return(@mysql_fetch_assoc($this->result));
                  }

             function freeresult()
                  {
                   return(@mysql_free_result($this->result));
                  }
}
?>[s]


Это сообщение отредактировал(а) PHP-Script - 17.6.2005, 22:51
PM MAIL ICQ   Вверх
Mal Hack
Дата 17.6.2005, 22:57 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Мудрый...
****


Профиль
Группа: Участник Клуба
Сообщений: 9926
Регистрация: 15.2.2004

Репутация: нет
Всего: 261



PHP-Script
Этот класс имхо не даст той универсальности.
ИМХО, слишком прост.
PM ICQ   Вверх
Рыжий
Дата 18.6.2005, 00:03 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Помешанный
***


Профиль
Группа: Завсегдатай
Сообщений: 1423
Регистрация: 19.9.2004

Репутация: нет
Всего: 20



Mal Hack
Будь проще и к тебе потянутся smile
а почему ты считаешь что нужно извращаться?? (просто вопрос для себя...)
PM MAIL ICQ   Вверх
Gold Dragon
Дата 18.6.2005, 10:53 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Призрачный
****


Профиль
Группа: Экс. модератор
Сообщений: 6753
Регистрация: 1.3.2004
Где: Россия, Тамбов

Репутация: нет
Всего: 71



а правда, чем плох этот простой класс?
Mal Hack, твой вариант что-то слишком навороченный (но может он и лучше smile ). Пояни тогда


--------------------
Нельзя жить в прошлом, оно уже прошло.
Нельзя жить в будущем, оно ещё не наступило.
Нужно жить в настоящем, помня прошлое и думая о будущем!
PM MAIL WWW ICQ   Вверх
Wowa
Дата 18.6.2005, 11:37 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
Group Icon


Профиль
Группа: Админ
Сообщений: 15017
Регистрация: 14.9.2000
Где: Винград

Репутация: нет
Всего: 290



Мне нравится мой вариант smile
PM WWW   Вверх
Рыжий
Дата 18.6.2005, 12:04 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Помешанный
***


Профиль
Группа: Завсегдатай
Сообщений: 1423
Регистрация: 19.9.2004

Репутация: нет
Всего: 20



Ну вот, начинается лебедь рак и щука - каждый в свою сторону... smile
PM MAIL ICQ   Вверх
Opik
Дата 18.6.2005, 14:12 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
***


Профиль
Группа: Vingrad developer
Сообщений: 1918
Регистрация: 6.10.2004
Где: Рига

Репутация: нет
Всего: 55



Думаю класс не нужен, ибо будем ориентироваться на развитие PHP?
А в такой штуке как PHP 5.1 есть другая штука - PDO
http://ee.php.net/pdo
PM MAIL Skype   Вверх
Wowa
Дата 18.6.2005, 14:27 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
Group Icon


Профиль
Группа: Админ
Сообщений: 15017
Регистрация: 14.9.2000
Где: Винград

Репутация: нет
Всего: 290



Цитата(Opik @ 18.6.2005, 13:12)
Думаю класс не нужен, ибо будем ориентироваться на развитие PHP?
А в такой штуке как PHP 5.1 есть другая штука - PDO
http://ee.php.net/pdo

Очень хорошо, но пока это вещь сырая - думаю нужен собственный класс. Методы можно назвать также. Чтобы в будущем при необходимости подменить одно - другим не составило труда.
PM WWW   Вверх
Opik
Дата 18.6.2005, 14:31 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
***


Профиль
Группа: Vingrad developer
Сообщений: 1918
Регистрация: 6.10.2004
Где: Рига

Репутация: нет
Всего: 55



Wowa
Я думаю лучше сразу писать на эту вещь, хоть и сыроватую..А потом, если она сгинет (тьфу тьфу тьфу) то написать аналогичный класс.
PM MAIL Skype   Вверх
Wowa
Дата 18.6.2005, 15:40 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
Group Icon


Профиль
Группа: Админ
Сообщений: 15017
Регистрация: 14.9.2000
Где: Винград

Репутация: нет
Всего: 290



Цитата(Opik @ 18.6.2005, 13:31)
Я думаю лучше сразу писать на эту вещь, хоть и сыроватую..А потом, если она сгинет (тьфу тьфу тьфу) то написать аналогичный класс.

Для этого надо всем ставить новейшую версию ПХП. А если будут найдены баги, то снова ПХП обновлять. Обновление ПХП на веб-серверах - частенько не так легко и быстро, как кажется.
PM WWW   Вверх
Ответ в темуСоздание новой темы Создание опроса
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Vingrad CMS | Следующая тема »


 




[ Время генерации скрипта: 0.1904 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.