Four types of articles encapsulate various operations on articles, such as inserting data into the database and extracting data from the database. WHXBB ();} *** An error occurred while writing an article to the database * @ param $ title article title * @ param $ author article author * @ param $ content article content * @ return: A WHXBB_Error object is successfully created. WHXBB ();}/*** writing an article to the database * @ param $ title article title * @ param $ author article author * @ param $ content article content * @ return operation error: successful WHXBB_Error: true * @ access public */function Insert ($ title, $ author, $ content) {new WHXBB_Debug ("Insert () Start "); // process the passed WHXBB: OperateString (& $ title, in); WHXBB: OperateString (& $ author, in); WHXBB: OperateString (& $ content, in); $ SQL = "insert into article (title, author, content) va Lues ($ title, $ author, $ content) "; if (! @ Mysql_query ($ SQL, $ this-> _ conn) {return new WHXBB_Error ("Insert () Failed. ($ SQL) ", 1021);} new WHXBB_Debug (" Insert () Completed "); return true ;} /*** delete the specified record * @ param $ id the id of the record to be deleted * @ return operation error: A WHXBB_Error object succeeded: true * @ access public */function Del ($ id) {new WHXBB_Debug ("Del ($ id) Start"); $ SQL = "delete from article where id = $ id) "; if (! @ Mysql_query ($ SQL, $ this-> _ conn) {return new WHXBB_Error ("Del () Failed. ($ SQL) ", 1024);} new WHXBB_Debug (" Dle ($ id) Completed "); return true ;} /*** get the total number of articles * @ param $ condition query condition * @ return operation error: A WHXBB_Error object succeeded: true * @ access public */function GetCount ($ condition =) {new WHXBB_Debug ("GetCount () Start"); $ SQL = "select count (id) from article where 1 = 1 $ condition"; if (! $ Result = @ mysql_query ($ SQL, $ this-> _ conn) {return new WHXBB_Error ("GetCount () Failed. ($ SQL) ", 1000);} list ($ count) = @ mysql_fetch_array ($ result); @ mysql_free_result ($ result); new WHXBB_Debug (" GetCount () completed "); return $ count;}/*** get all the field information of an article * @ param $ id article id number * @ return operation error: A WHXBB_Error object succeeded: no information is returned for an associated array: 0 * @ access public */function GetInfo ($ id) {new WHXBB_Debug ("GetInfo ($ Id) Start "); $ SQL =" select id, title, content, author from article where id = $ id "; $ result = @ mysql_query ($ SQL, $ this-> _ conn); if (! $ Result) return new WHXBB_Error ("GetInfo ($ id) Failed. ($ SQL) ", 1002); if (@ mysql_num_rows ($ result) = 0) return 0; $ info = @ mysql_fetch_array ($ result ); while (list ($ var, $ key) = each ($ info) {WHXBB: OperateString (& $ info [$ var], out );} reset ($ info); @ mysql_free_result ($ result); new WHXBB_Debug ("GetInfo ($ id) Completed"); return $ info ;} /*** get all the records whose author is the specified author name * @ param $ items displays the number of records per page. if it is 0, all records are retrieved. * @ Param page current page number * @ param author name * @ param $ orderBy sorting method * @ return operation error: A WHXBB_Error object succeeded: an array cannot be found: returns 0 * @ access public */function GetNInfoByAuthor ($ items, $ page, $ author, $ orderBy = order by id desc) {WHXBB: OperateString (& $ author, in); $ condition = "and author = $ author"; $ result = $ this-> GetNInfo ($ items, $ page, $ condition, $ orderBy ); return $ result;}/*** list all records * @ param $ items The number of entries per page. if it is 0, all records are Retrieved * @ param $ page current page number * @ param $ condition query condition * @ param $ orderBy sorting method * @ return operation error: success of a WHXBB_Error object: a two-dimensional array cannot be found: 0 * @ access public */function GetNInfo ($ items, $ page, $ condition =, $ orderBy = order by id desc) {new WHXBB_Debug ("GetNInfo () Start"); $ limit =; // Retrieve the total number of records $ infoCount = $ this-> GetCount ($ condition); if ($ infoCount = 0) return 0; if ($ items! = 0) {// create a new page splitter $ this-> pager = new Pager ($ infoCount, $ items, $ page); $ startPos = $ this-> pager-> startPos; $ limit = "limit ". $ startPos. ",". $ items;} $ SQL = "select id, title, author from article where 1 = 1 $ condition $ orderBy $ limit"; $ result = @ mysql_query ($ SQL, $ this-> _ conn); if (! $ Result) return new WHXBB_Error ("GetNInfo () Failed. ($ SQL) ", 1001); if (@ mysql_num_rows ($ result) = 0) return 0; $ I = 0; while ($ arr = @ mysql_fetch_array ($ result) {while (list ($ var, $ key) = each ($ arr) {WHXBB :: operateString (& $ arr [$ var], out);} reset ($ arr); $ info [$ I] = $ arr; $ I ++ ;} @ mysql_free_result ($ result); new WHXBB_Debug ("GetNInfo () Completed"); return $ info ;}}?>
Http://www.bkjia.com/PHPjc/532122.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/532122.htmlTechArticleWHXBB ();}/*** article write database * @ param $ title article title * @ param $ author article author * @ param $ content article content * @ return operation error: A WHXBB_Error object is successfully created...