PHP-Mysql Operation Problems

Source: Internet
Author: User
Simple operation class {code...} call method {code...} first {code...} This statement can be found to be worth it. I don't know why var_dump ($ orderResult) is NULL. It may be because there is a problem in instantiating the same class! I don't know how to write this class? Simple operations

  Conn = mysql_connect ($ server, $ userName, $ password, true) or die ('connect MySQL DB error! '); Mysql_select_db ($ database, $ this-> conn) or die ('select db error! '); Mysql_query ("set names ". $ charset, $ this-> conn);}/*** + --------------------------------- * | @ param $ type select, insert, delete, updata * + ----------------------------- ***/public function query ($ sqlQuery, $ type) {$ this-> stmt = mysql_query ($ sqlQuery); if ($ this-> stmt) {switch ($ type) {case 'select': $ data = array (); while ($ row = mysql_fetch_array ($ this-> stmt, MYSQL_ASSOC )) {$ data [] = $ row;} return $ data; break; case 'insert': return mysql_insert_id (); break; case 'updat': return mysql_affected_rows (); break; case 'delete': return mysql_affected_rows (); break; default: return "Please, enter '\ $ type'"; break ;}} function _ destruct () {@ mysql_free_result ($ this-> stmt); mysql_close ($ this-> conn );}}
Call Method

  = mktime(12,0,0))    {        $begin = mktime(0,0,0);        $end   = mktime(11,59,59);    }    else    {        $begin = mktime(12,0,0,date("m"),date("d")-1,date("Y"));        $end = mktime(23,59,59,date("m"),date("d")-1,date("Y"));    }    $begin = mktime(0,0,0,1,1,2013);    $end   = mktime(0,0,0,12,31,2014);    $orderQuery = "select sum(goods.goods_nums) as `goods_nums`,goods.goods_id as `goods_id`                     from iwebshop_order_goods as goods left join iwebshop_order as `order` on `order`.id = goods.order_id                     where `status` = '5' and unix_timestamp(`order`.completion_time)                     between '".$begin."' and '".$end ."' group by goods.goods_id";    $orderResult =  $njhl->query($orderQuery,'select');    var_dump($orderResult);

First

select sum(goods.goods_nums) as `goods_nums`,goods.goods_id as `goods_id`                     from iwebshop_order_goods as goods left join iwebshop_order as `order` on `order`.id = goods.order_id                     where `status` = '5' and unix_timestamp(`order`.completion_time)                     between '1356969600' and '1419955200' group by goods.goods_id

This statement can be queried.

I don't know whyvar_dump($orderResult)IndeedNULLIt may be that there is a problem with instantiating the same class!
I don't know how to write this class?

Reply content: simple operations

  Conn = mysql_connect ($ server, $ userName, $ password, true) or die ('connect MySQL DB error! '); Mysql_select_db ($ database, $ this-> conn) or die ('select db error! '); Mysql_query ("set names ". $ charset, $ this-> conn);}/*** + --------------------------------- * | @ param $ type select, insert, delete, updata * + ----------------------------- ***/public function query ($ sqlQuery, $ type) {$ this-> stmt = mysql_query ($ sqlQuery); if ($ this-> stmt) {switch ($ type) {case 'select': $ data = array (); while ($ row = mysql_fetch_array ($ this-> stmt, MYSQL_ASSOC )) {$ data [] = $ row;} return $ data; break; case 'insert': return mysql_insert_id (); break; case 'updat': return mysql_affected_rows (); break; case 'delete': return mysql_affected_rows (); break; default: return "Please, enter '\ $ type'"; break ;}} function _ destruct () {@ mysql_free_result ($ this-> stmt); mysql_close ($ this-> conn );}}
Call Method

  = mktime(12,0,0))    {        $begin = mktime(0,0,0);        $end   = mktime(11,59,59);    }    else    {        $begin = mktime(12,0,0,date("m"),date("d")-1,date("Y"));        $end = mktime(23,59,59,date("m"),date("d")-1,date("Y"));    }    $begin = mktime(0,0,0,1,1,2013);    $end   = mktime(0,0,0,12,31,2014);    $orderQuery = "select sum(goods.goods_nums) as `goods_nums`,goods.goods_id as `goods_id`                     from iwebshop_order_goods as goods left join iwebshop_order as `order` on `order`.id = goods.order_id                     where `status` = '5' and unix_timestamp(`order`.completion_time)                     between '".$begin."' and '".$end ."' group by goods.goods_id";    $orderResult =  $njhl->query($orderQuery,'select');    var_dump($orderResult);

First

select sum(goods.goods_nums) as `goods_nums`,goods.goods_id as `goods_id`                     from iwebshop_order_goods as goods left join iwebshop_order as `order` on `order`.id = goods.order_id                     where `status` = '5' and unix_timestamp(`order`.completion_time)                     between '1356969600' and '1419955200' group by goods.goods_id

This statement can be queried.

I don't know whyvar_dump($orderResult)IndeedNULLIt may be that there is a problem with instantiating the same class!
I don't know how to write this class?

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.