问题
I am writing query in view tpl but i don't know how to get database details and execute that query in views in opencart.Here is my code
$query=mysql_query("select $prefixorder from opencart ");
回答1:
why bothering your self with writing queries using native functions, open cart provides some stuff for you
- First, read this article, it's great and helped me a lot Here
- You can now execute the query through
$result = $this->db->query("write your query here");
You can get the number of returned rows through$result->num_rows
, you can access the first row directly through$result->row
which is an associative array that contains key/value pairs of the first row only, finally you can access all rows through$result->rows
which is an array of associative arrays
来源:https://stackoverflow.com/questions/28468284/how-to-get-database-details-is-views-in-opencart