public function setData(array $data) { $mysql = new MMysql($this->_config['db']); $mysql->startTrans(); $mysql->insert('notices', $data); $mysql->commit(); }
public function login() { $mysql = new MMysql($this->_config['db']); $ary = $mysql->field('*')->where('user="******"')->select('users'); if (count($ary) > 0) { return $ary[0]['pwd'] == $this->_pwd; } else { return false; } }
private function setData($json) { $mysql = new MMysql($this->_config['db']); $_ary = json_decode($json); $isExists = $mysql->field('count(1) as ct')->where(array('sku' => '"' . $_ary->sku . '"', 'lotid' => array('"' . $_ary->lotid . '"', '=', 'and'), 'supplyid' => array('"' . $_ary->supplyid . '"', '=', 'and')))->select('yy_reports'); if ((int) $isExists[0]['ct'] == 0) { $data = array('sku' => $_ary->sku, 'lotid' => $_ary->lotid, 'spec' => $_ary->spec, 'cdname' => $_ary->cdname, 'cdcode' => $_ary->cdcode, 'supplyid' => $_ary->supplyid, 'spname' => $_ary->spname, 'spcode' => $_ary->spcode, 'picpath' => $_ary->picpath); $mysql->insert('yy_reports', $data); return true; } return false; }
public function getData($act, array $param = NULL) { if ($act == 'list') { $mysql = new MMysql($this->_config['db']); $ary = $mysql->field('*')->order('addtime desc')->limit(1, 10)->select('news'); return $ary; } else { if ($act == 'index') { $active = $param['act']; $ary = array('Menus' => array(array('active' => $active == 'list', 'url' => '/admin/templates/list', 'name' => '模版列表'), array('active' => $active == 'add', 'url' => '/admin/templates/add', 'name' => '添加模版'))); return $ary; } } }
public function getData($sku, $lotid) { $mysql = new MMysql($this->_config['db']); if (!empty($sku)) { $where = '(spname like "%' . $sku . '%" or spcode like "%' . $sku . '%")'; } else { return null; } if (!empty($lotid)) { $where = $where . ' and lotid="' . $lotid . '"'; } $isExists = $mysql->field('*')->where($where)->select('yy_reports'); return $isExists; }
/** * 关闭连接 * PHP 在脚本结束时会自动关闭连接。 */ public function close() { if (!is_null(self::$_dbh)) { self::$_dbh = null; } }
<?php include 'MMysql.php'; $mysql = new MMysql(); //插入 $data = array('name' => "忽必烈", 'sex' => 1, 'tel' => 16558656367); $mysql->insert('user_list', $data); //查询 $res = $mysql->field(array('name', 'sex', 'tel'))->select('user_list'); // $res = $mysql->field('sid,aa,bbc') // ->order('sid desc,aa asc') // ->where('sid=101 or aa>123455') // ->limit(1,2) // ->select('t_table'); echo "xxxxx query=> " . count($res) . " first person: " . $res[1]['name']; echo "<br>"; //获取最后执行的sql语句 $sql = $mysql->getLastSql(); //直接执行sql语句 $sql = "show tables"; $res = $mysql->doSql($sql); echo "<br>"; echo "xxxxx show=> " . count($res) . " first: " . $res[0];