当前位置: 首页>>代码示例>>PHP>>正文


PHP pdo函数代码示例

本文整理汇总了PHP中pdo函数的典型用法代码示例。如果您正苦于以下问题:PHP pdo函数的具体用法?PHP pdo怎么用?PHP pdo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pdo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: importFromErp_handler

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);
}
开发者ID:ruige123456,项目名称:dataMining,代码行数:39,代码来源:dbexchange.func.php

示例2: foreach

$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;
}
开发者ID:eduNeusoft,项目名称:weixin,代码行数:31,代码来源:process.ctrl.php

示例3: cloud_schema

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;
}
开发者ID:7demo,项目名称:we7,代码行数:30,代码来源:cloud.mod.php

示例4: load

         }
     }
     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;
                 }
             }
         }
     }
开发者ID:hahamy,项目名称:we7,代码行数:31,代码来源:database.ctrl.php

示例5: pdo_indexexists

function pdo_indexexists($tablename, $indexname = '')
{
    return pdo()->indexexists($tablename, $indexname);
}
开发者ID:yunsite,项目名称:my-we7,代码行数:4,代码来源:pdo.func.php

示例6: delete_job_application

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());
    }
}
开发者ID:jomla97,项目名称:overtion,代码行数:10,代码来源:model.php

示例7: set_pdo

 /**
  * modifie l'instance de la connection PDO
  *
  * @param PDO $pdo
  * @return PDO
  */
 function set_pdo(PDO $pdo)
 {
     Database::setPdo($pdo);
     return pdo();
 }
开发者ID:papac,项目名称:framework,代码行数:11,代码来源:helper.php

示例8: 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>
开发者ID:jomla97,项目名称:mathandel,代码行数:31,代码来源:sorting-list.php

示例9: get_header

*/
# 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 />';
开发者ID:Hastwell,项目名称:ITC250-W16-GrpProj3,代码行数:31,代码来源:demo_pdo.php

示例10: insertExecute

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");
    }
}
开发者ID:bschwartz757,项目名称:PHP-MySQL,代码行数:49,代码来源:demo_add_pdo.php

示例11: pdo_tableexists

function pdo_tableexists($tablename)
{
    return pdo()->tableexists($tablename);
}
开发者ID:keycoolkui,项目名称:weixinfenxiao,代码行数:4,代码来源:pdo.func.php

示例12: pdo_insertid

/**
 * 返回lastInsertId
 *
 */
function pdo_insertid()
{
    return pdo()->lastInsertId();
}
开发者ID:YongHaoWu,项目名称:gdpuer,代码行数:8,代码来源:pdo.func.php

示例13: pdo_run

function pdo_run($sql)
{
    return pdo()->run($sql);
}
开发者ID:liuguogen,项目名称:weixin,代码行数:4,代码来源:Update.class.php

示例14: db_getMyStationUser

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));
}
开发者ID:ruige123456,项目名称:dataMining,代码行数:6,代码来源:business.func.php

示例15: add_to_basket

	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);
	}
开发者ID:jomla97,项目名称:mathandel,代码行数:12,代码来源:model.php


注:本文中的pdo函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。