Tài liệu Bài test vị trí lập trình viên

Thảo luận trong 'Lập Trình' bắt đầu bởi Thúy Viết Bài, 5/12/13.

  1. Thúy Viết Bài

    Thành viên vàng

    Bài viết:
    198,891
    Được thích:
    167
    Điểm thành tích:
    0
    Xu:
    0Xu
    1. Đoạn mã này có tác dụng gì? Hãy sửa lại một số đoạn lỗi.


    <?php



    // abstract class for working with table records as database objects

    Class DBObject{



    var $tableName;

    var $fieldPrefix;

    // sql library that you can use to make queries, fetch results, etc.

    var $sqlLib;



    // constructor, pass table name and field prefix as parameters

    function DBObject($table, $prefix){

    // set table name

    if (!empty($table)){

    $this -> tableName = $table;

    }else{

    $this -> errors[] = 'DBObject: Table name cannot be empty!';

    }



    // set field prefix

    if (!empty($prefix)){

    $this -> fieldPrefix = $prefix;

    }else{

    $this -> errors[] = 'DBObject: Fieldname prefix cannot be empty!';

    }



    // instantinate Singleton pattern of MySQL class

    $this -> sqlLib = MySQL::instance();

    }



    // get object from database, return all fields by given id

    function getObject($id){

    $qry = SELECT * FROM . $this -> tableName . WHERE . $this -> fieldPrefix . id = $id;

    $this -> sqlLib -> query($qry);

    return $this -> sqlLib -> fetchAssoc();
     

    Các file đính kèm:

Đang tải...
Chủ đề tương tự
  1. thegioido111
    Trả lời:
    0
    Xem:
    1,086
  2. Thúy Viết Bài

    Tài liệu Bài tập Java

    Thúy Viết Bài, 5/12/13, trong diễn đàn: Lập Trình
    Trả lời:
    0
    Xem:
    742
  3. Thúy Viết Bài
    Trả lời:
    0
    Xem:
    572
  4. Thúy Viết Bài
    Trả lời:
    0
    Xem:
    1,012
  5. Thúy Viết Bài
    Trả lời:
    0
    Xem:
    583