function importFromErp_handler($guid) { global $_W; //set_error_handler('process_Exception_handler',E_ALL ^ ~E_NOTICE ^ E_WARNING ); $progress = 10; $error = false; updateProgress($progress, '导入项目信息'); if (importErp_Project($guid)) { showLog('导入项目信息成功'); updateProgress(10, '导入出错'); } else { showLog('导入出错'); updateProgress(-1, '导入出错'); return false; } $calls = array('AllOption' => '主体项目', 'BuildInfo' => '楼盘信息', 'UserInfo' => '用户信息', 'ProjCustomer' => '客户信息', 'ProjPayAndDiscount' => '支付及折扣信息', 'ProjInvoice' => '票据信息'); $step = 15; $clear = false; pdo()->setShowDebugExcept(true); foreach ($calls as $c => $m) { $progress += $step; updateProgress($progress, '正在获取' . $m); $function = 'importErp_' . $c; try { $function($guid, true); } catch (Exception $e) { showLog('导入' . $m . '出错:' . $e->getMessage() . '<br>'); $error = true; } sleep(1); } //更新项目状态 if (!$error) { pdo_update('project', array('status' => 1), array('projguid' => $guid)); } showLog('导入完成'); updateProgress(100, '导入完成'); pdo()->setShowDebugExcept(false); }
$packet['files'][] = "/stonefish_planting/template/userinfo.html"; $packet['files'][] = "/stonefish_planting/template/sharelist.html"; /*引导错误*/ $packet['files'][] = "/hx_donate/icon1111.jpg"; if ($step == 'schemas' && $_W['ispost']) { $post = $_GPC['__input']; $tablename = $post['table']; foreach ($packet['schemas'] as $schema) { if (substr($schema['tablename'], 4) == $tablename) { $remote = $schema; break; } } if (!empty($remote)) { load()->func('db'); $local = db_table_schema(pdo(), $tablename); $sqls = db_table_fix_sql($local, $remote); $error = false; foreach ($sqls as $sql) { if (pdo_query($sql) === false) { $error = true; $errormsg .= pdo_debug(false); break; } } if (!$error) { exit('success'); } } exit; }
function cloud_schema() { $pars = _cloud_build_params(); $pars['method'] = 'application.schema'; $dat = cloud_request('http://v2.addons.we7.cc/gateway.php', $pars); $file = IA_ROOT . '/data/application.schema'; $ret = _cloud_shipping_parse($dat, $file); if (!is_error($ret)) { $schemas = array(); if (!empty($ret['schemas'])) { load()->func('db'); foreach ($ret['schemas'] as $remote) { $name = substr($remote['tablename'], 4); $local = db_table_schema(pdo(), $name); unset($remote['increment']); unset($local['increment']); if (empty($local)) { $schemas[] = $remote; } else { $diffs = db_schema_compare($local, $remote); if (!empty($diffs)) { $schemas[] = $remote; } } } } $ret['schemas'] = $schemas; } return $ret; }
} } exit; } load()->model('cloud'); $r = cloud_prepare(); if (is_error($r)) { message($r['message'], url('cloud/profile'), 'error'); } $upgrade = cloud_schema(); $schemas = $upgrade['schemas']; if (!empty($schemas)) { load()->func('db'); foreach ($schemas as $key => $value) { $tablename = substr($value['tablename'], 4); $struct = db_table_schema(pdo(), $tablename); if (!empty($struct)) { $temp = db_schema_compare($schemas[$key], $struct); $diff[$tablename]['name'] = $value['tablename']; if (!empty($temp['fields']['less'])) { foreach ($temp['fields']['less'] as $key => $value) { $diff[$tablename]['fields'][] = $value; } } if (!empty($temp['indexes']['less'])) { foreach ($temp['indexes']['less'] as $key => $value) { $diff[$tablename]['indexes'][] = $value; } } } }
function pdo_indexexists($tablename, $indexname = '') { return pdo()->indexexists($tablename, $indexname); }
function delete_job_application($id) { $pdo = pdo(); $statement = $pdo->prepare("DELETE FROM job_applications WHERE id LIKE '{$id}'"); if ($statement->execute()) { header("location:index.php?page=job_applications"); } else { print_r($statement->errorInfo()); } }
/** * modifie l'instance de la connection PDO * * @param PDO $pdo * @return PDO */ function set_pdo(PDO $pdo) { Database::setPdo($pdo); return pdo(); }
<!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="stylesheets/sorting-list.css"> </head> <body> <ul id="sorting-list-wrapper"> <li id="sorting-list-title"><h1>Snabbnavigering</h1><img src="res/not-expanded-arrow-icon.png" alt="expand" title="expand"></li> <?php $pdo = pdo(); foreach($pdo->query("SELECT name FROM categories") as $category){ echo ' <li class="category"> <a href="index.php?page=browse&sort_by=' . $category['name'] . '"><h2>' . $category['name'] . '</h2></a> <img src="res/not-expanded-arrow-icon.png" alt="expand" title="expand"> <ul> '; $sort_by = $category['name']; foreach ($pdo->query("SELECT * FROM products WHERE category LIKE '$sort_by'") as $product) { echo ' <a href="index.php?page=product&id=' . $product['id'] . '"><li class="sorting-list-product"><p>' . $product['name'] . '</p></li></a> '; } echo ' </ul> </li>'; } ?> </ul>
*/ # SQL statement - PREFIX is optional way to distinguish your app $sql = "select FirstName, LastName, Email from test_Customers"; //END CONFIG AREA ---------------------------------------------------------- get_header(); #defaults to header_inc.php ?> <h3 align="center"><?php echo $config->titleTag; ?> </h3> <p>This page is both a test page for your PDO connection, and a starting point for building DB applications using PDO connections</p> <p>creates a simple PDO connection via the function pdo()</p> <?php $db = pdo(); # pdo() creates and returns a PDO object #$result stores data object in memory try { $result = $db->query($sql); } catch (PDOException $ex) { trigger_error($ex->getMessage(), E_USER_ERROR); } echo '<div align="center"><h4>SQL STATEMENT: <font color="red">' . $sql . '</font></h4></div>'; if ($result->rowCount() > 0) { #there are records - present data while ($row = $result->fetch(PDO::FETCH_ASSOC)) { # pull data from associative array echo '<p>'; echo 'FirstName: <b>' . $row['FirstName'] . '</b><br />'; echo 'LastName: <b>' . $row['LastName'] . '</b><br />';
function insertExecute() { //$FirstName = strip_tags($_POST['FirstName']); //$LastName = strip_tags($_POST['LastName']); //$Email = strip_tags($_POST['Email']); $FirstName = $_POST['FirstName']; $LastName = $_POST['LastName']; $Email = $_POST['Email']; $db = pdo(); # pdo() creates and returns a PDO object //dumpDie($FirstName); //PDO Quote has some great stuff re: injection: //http://www.php.net/manual/en/pdo.quote.php //next check for specific issues with data /* if(!ctype_graph($_POST['FirstName'])|| !ctype_graph($_POST['LastName'])) {//data must be alphanumeric or punctuation only feedback("First and Last Name must contain letters, numbers or punctuation"); myRedirect(THIS_PAGE); } if(!onlyEmail($_POST['Email'])) {//data must be alphanumeric or punctuation only feedback("Data entered for email is not valid"); myRedirect(THIS_PAGE); } */ //build string for SQL insert with replacement vars, ? $sql = "INSERT INTO test_Customers (FirstName, LastName, Email) VALUES (?,?,?)"; $stmt = $db->prepare($sql); //INTEGER EXAMPLE $stmt->bindValue(1, $id, PDO::PARAM_INT); $stmt->bindValue(1, $FirstName, PDO::PARAM_STR); $stmt->bindValue(2, $LastName, PDO::PARAM_STR); $stmt->bindValue(3, $Email, PDO::PARAM_STR); try { $stmt->execute(); } catch (PDOException $ex) { trigger_error($ex->getMessage(), E_USER_ERROR); } #feedback success or failure of update if ($stmt->rowCount() > 0) { //success! provide feedback, chance to change another! feedback("Customer Added Successfully!", "success"); } else { //Problem! Provide feedback! feedback("Customer NOT added!", "warning"); } }
function pdo_tableexists($tablename) { return pdo()->tableexists($tablename); }
/** * 返回lastInsertId * */ function pdo_insertid() { return pdo()->lastInsertId(); }
function pdo_run($sql) { return pdo()->run($sql); }
function db_getMyStationUser($projGUID) { $sql = "SELECT b.* FROM ims_mystation a INNER JOIN ims_mystationuser b ON a.StationGUID = b.StationGUID "; $sql .= " where a.ProjGUID=:ProjGUID"; return pdo()->fetchall($sql, array(':ProjGUID' => $projGUID)); }
function add_to_basket($id, $quantity){ $pdo = pdo(); for($quantity; $quantity > 0; $quantity--){ $statement = $pdo->prepare("INSERT INTO baskets (username, item_id) VALUES (?, ?)"); $statement->bindParam(1, $_SESSION['username']); $statement->bindParam(2, $id); $statement->execute(); } header("location:index.php?page=product&id=" . $id); }