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