ホームページ php教程 PHP源码 动态 bindVars 的用法

动态 bindVars 的用法

May 25, 2016 pm 05:14 PM

动态 bindVars 的用法

private function bindVars($stmt,$params) {
    if ($params != null) {
        $types = '';                        //initial sting with types
        foreach($params as $param) {        //for each element, determine type and add
            if(is_int($param)) {
                $types .= 'i';              //integer
            } elseif (is_float($param)) {
                $types .= 'd';              //double
            } elseif (is_string($param)) {
                $types .= 's';              //string
            } else {
                $types .= 'b';              //blob and unknown
            }
        }
 
        $bind_names[] = $types;             //first param needed is the type string
                                            // eg:  'issss'
 
        for ($i=0; $i<count($params);$i++) {//go through incoming params and added em to array
            $bind_name = &#39;bind&#39; . $i;       //give them an arbitrary name
            $$bind_name = $params[$i];      //add the parameter to the variable variable
            $bind_names[] = &$$bind_name;   //now associate the variable as an element in an array
        }
 
                                            //call the function bind_param with dynamic params
        call_user_func_array(array($stmt,&#39;bind_param&#39;),$bind_names);
    }
    return $stmt;                           //return the bound statement
ログイン後にコピー

                   


このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)