小编Sui*_* Go的帖子

哪种方法是将数据添加到数据库?

$user='root';

try{
$pdo=new PDO('mysql:host=localhost;dbname=test',$user);
$pdo->exec('set character set utf8');
}
catch(PDOException $e){
echo 'Error: '.$e->getMessage();
}

//using bound variables?
$stmt=$pdo->prepare('insert into test(name) value(:name)');
$stmt->bindParam(':name',$_POST['name']);
$stmt->execute();

//using named parameters
$stmt=$pdo->prepare('insert into test(name) value(:name)');
$stmt->execute(array(':name'=>$_POST['name']));

//using placeholders
$stmt=$pdo->prepare('insert into test(name) value(?)');
$stmt->execute(array($_POST['name']));

//using bound parameters w/ placeholders
$stmt=$pdo->prepare('insert into test(name) value(?)');
$stmt->bindParam($_POST['name']);
$stmt->execute();
Run Code Online (Sandbox Code Playgroud)

我只是想知道什么是最好用作我的PHP启动器,我只是混淆了什么使用,我想知道什么是最好的和常用的.

php sql

4
推荐指数
1
解决办法
126
查看次数

当我使用任务秒表时,将显示经过的时间,但是当我使用线程时,它将不会显示.这是为什么?

我很困惑,为什么当我使用任务秒表的时间会显示但是当我使用线程时它不会.我的代码出了什么问题?我错过了什么吗?

static void Main(string[] args)
    {
        Stopwatch sw = new Stopwatch();
        sw.Start();

        //if I used this sw.Elapsed will display
        //Task t1 = Task.Factory.StartNew(runTask1);
        //Task t2 = Task.Factory.StartNew(runTask2);
        //Task.WaitAll(t1, t2);

        //if I used this sw.Elapsed will not display
        //Thread t1 = new Thread(runTask1);
        //Thread t2 = new Thread(runTask2);
        //t1.Start();
        //t2.Start();

        sw.Stop();

        Console.WriteLine(sw.Elapsed);

        Console.ReadLine();
    }

    public static void runTask1()
    {
        for (int x = 1; x <= 5000; x++)
        {
            Console.WriteLine("Run task tester 1");
        }
    }
    public static void runTask2()
    {
        for …
Run Code Online (Sandbox Code Playgroud)

c# multithreading task task-parallel-library

0
推荐指数
1
解决办法
523
查看次数

标签 统计

c# ×1

multithreading ×1

php ×1

sql ×1

task ×1

task-parallel-library ×1