PHP Database Operation Helper Class full instance ituneshelper error missing helper IP helper where

Source: Internet
Author: User
Tags php class php database ituneshelper
The example in this article describes the PHP database manipulation helper class. Share to everyone for your reference, as follows:

The PHP operations database is divided into several steps (here, for example, MySQL):

1. Establish a connection

$c

2. Select a database

$db _select=mysql_select_db ($db _database);

3. Performing CRUD Operations

mysql_query ("Set names ' UTF8 '");//Encode $result=mysql_query ($sqlstring);

(Mysql_affected_rows () the number of record lines affected by the previous MySQL operation)

4. Enquiry

Mysql_fetch_array ($result); mysql_fetch_row ($result);

5. Close the connection

Mysql_close ($connection);

dbhelper.php class file:

<?phpclass dbhelper{  //Establish connection  function getconnection ($db _host, $db _username, $db _password)  {    $c    if ($c die      ("Database connection failed:". Mysql_error ());//Enter a specific error message    return $connection;  }  Select the corresponding database  function dbselect ($db _database)  {    $db _select=mysql_select_db ($db _database);    if ($db _select==false) die      ("Database selection failed:". Mysql_error ());    return $db _select;  }  Perform crud operation  function Excute ($sqlstring)  {    $result =mysql_query ($sqlstring);    return $result;  }  Frees resource  function CloseConnection ($connection)  {    if ($connection!=null)    mysql_close ($ connection);}  }? >

dbtext.php configuration file:

<?php$db_host= "localhost", $db _database= "Mymessage", $db _username= "root"; $db _password= "123456";? >

More interested in PHP related content readers can view this site topic: "PHP based on PDO operation database Tips Summary", "PHP+MONGODB Database operation Skills Daquan", "PHP Object-oriented Programming tutorial", "PHP String Usage Summary", " Php+mysql database Operation Tutorial "and" PHP common database Operation Skills Summary "

I hope this article is helpful to you in PHP programming.

The above describes the PHP database Operation helper Class complete example, including the helper aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.