Ecshop database operation Methods GetRow, GETALL, getone differences

Source: Internet
Author: User

Ecshop does not use some open-source database operation classes, such as ADODB or pear, but encapsulates its own implementation. The benefit of this is a very lightweight implementation, which greatly reduces the file size of the distribution package. In addition, when the site needs to do memcached cache, it can also be very convenient to implement.

Of course, the consequence of this is that the choice of database is very narrow, unable to implement other non-MySQL database.

The Ecshop data manipulation class file is includes/cls_mysql.php, and the class name is Cls_mysql.

This class mainly provides some of the more useful methods below:

getAll ($sql) and getallcached ($sql, $cached = ' Filefirst '): gets all records .

function GetAll ($sql)    {        $res = $this->query ($sql);        if ($res!== false)        {            $arr = array ();            while ($row = Mysql_fetch_assoc ($res))            {                $arr [] = $row;            }            return $arr;        }        else        {            return false;        }    }

GetRow ($sql, $limited = False) and getrowcached ($sql, $cached = ' Filefirst '): gets a single-line record.


Getcol ($sqlse) and getcolcached ($sql, $cached = ' Filefirst '): Gets all values for a field.
GetOne ($sql, $limited = False) and getonecached ($sql, $cached = ' Filefirst '): Gets a single value.

function GetOne ($sql, $limited = False)    {        if ($limited = = True)        {            $sql = Trim ($sql. ' LIMIT 1 ');        }        $res = $this->query ($sql);        if ($res!== false)        {            $row = mysql_fetch_row ($res);            if ($row!== false)            {                return $row [0];            }            else            {                return ';            }        }        else        {            return false;        }    }

  


Query ($SQL): Executes a database query.
Autoexecute ($table, $field _values, $mode = ' INSERT ', $where = '): Database table operation.

Ecshop database operation Methods GetRow, GETALL, getone differences

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.