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


PHP _array_change_key_case函数代码示例

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


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

示例1: _GenFields

 function _GenFields($flds, $widespacing = false)
 {
     if (is_string($flds)) {
         $padding = '     ';
         $txt = $flds . $padding;
         $flds = array();
         $flds0 = Lens_ParseArgs($txt, ',');
         $hasparam = false;
         foreach ($flds0 as $f0) {
             $f1 = array();
             foreach ($f0 as $token) {
                 switch (strtoupper($token)) {
                     case 'INDEX':
                         $f1['INDEX'] = '';
                         // fall through intentionally
                     // fall through intentionally
                     case 'CONSTRAINT':
                     case 'DEFAULT':
                         $hasparam = $token;
                         break;
                     default:
                         if ($hasparam) {
                             $f1[$hasparam] = $token;
                         } else {
                             $f1[] = $token;
                         }
                         $hasparam = false;
                         break;
                 }
             }
             // 'index' token without a name means single column index: name it after column
             if (array_key_exists('INDEX', $f1) && $f1['INDEX'] == '') {
                 $f1['INDEX'] = isset($f0['NAME']) ? $f0['NAME'] : $f0[0];
                 // check if column name used to create an index name was quoted
                 if (($f1['INDEX'][0] == '"' || $f1['INDEX'][0] == "'" || $f1['INDEX'][0] == "`") && $f1['INDEX'][0] == substr($f1['INDEX'], -1)) {
                     $f1['INDEX'] = $f1['INDEX'][0] . 'idx_' . substr($f1['INDEX'], 1, -1) . $f1['INDEX'][0];
                 } else {
                     $f1['INDEX'] = 'idx_' . $f1['INDEX'];
                 }
             }
             // reset it, so we don't get next field 1st token as INDEX...
             $hasparam = false;
             $flds[] = $f1;
         }
     }
     $this->autoIncrement = false;
     $lines = array();
     $pkey = array();
     $idxs = array();
     foreach ($flds as $fld) {
         $fld = _array_change_key_case($fld);
         $fname = false;
         $fdefault = false;
         $fautoinc = false;
         $ftype = false;
         $fsize = false;
         $fprec = false;
         $fprimary = false;
         $fnoquote = false;
         $fdefts = false;
         $fdefdate = false;
         $fconstraint = false;
         $fnotnull = false;
         $funsigned = false;
         $findex = '';
         $funiqueindex = false;
         //-----------------
         // Parse attributes
         foreach ($fld as $attr => $v) {
             if ($attr == 2 && is_numeric($v)) {
                 $attr = 'SIZE';
             } else {
                 if (is_numeric($attr) && $attr > 1 && !is_numeric($v)) {
                     $attr = strtoupper($v);
                 }
             }
             switch ($attr) {
                 case '0':
                 case 'NAME':
                     $fname = $v;
                     break;
                 case '1':
                 case 'TYPE':
                     $ty = $v;
                     $ftype = $this->ActualType(strtoupper($v));
                     break;
                 case 'SIZE':
                     $dotat = strpos($v, '.');
                     if ($dotat === false) {
                         $dotat = strpos($v, ',');
                     }
                     if ($dotat === false) {
                         $fsize = $v;
                     } else {
                         $fsize = substr($v, 0, $dotat);
                         $fprec = substr($v, $dotat + 1);
                     }
                     break;
                 case 'UNSIGNED':
                     $funsigned = true;
//.........这里部分代码省略.........
开发者ID:jnugh,项目名称:Paradise-Bird-Project,代码行数:101,代码来源:adodb-datadict.inc.php

示例2: _adodb_getinsertsql

/**
 * There is a special case of this function for the oci8 driver.
 * The proper way to handle an insert w/ a blob in oracle requires
 * a returning clause with bind variables and a descriptor blob.
 *
 *
 */
function _adodb_getinsertsql(&$zthis, &$rs, $arrFields, $magicq = false, $force = 2)
{
    static $cacheRS = false;
    static $cacheSig = 0;
    static $cacheCols;
    global $ADODB_QUOTE_FIELDNAMES;
    $tableName = '';
    $values = '';
    $fields = '';
    $recordSet = null;
    $arrFields = _array_change_key_case($arrFields);
    $fieldInsertedCount = 0;
    if (is_string($rs)) {
        //ok we have a table name
        //try and get the column info ourself.
        $tableName = $rs;
        //we need an object for the recordSet
        //because we have to call MetaType.
        //php can't do a $rsclass::MetaType()
        $rsclass = $zthis->rsPrefix . $zthis->databaseType;
        $recordSet = new $rsclass(-1, $zthis->fetchMode);
        $recordSet->connection = $zthis;
        if (is_string($cacheRS) && $cacheRS == $rs) {
            $columns = $cacheCols;
        } else {
            $columns = $zthis->MetaColumns($tableName);
            $cacheRS = $tableName;
            $cacheCols = $columns;
        }
    } else {
        if (is_subclass_of($rs, 'adorecordset')) {
            if (isset($rs->insertSig) && is_integer($cacheRS) && $cacheRS == $rs->insertSig) {
                $columns = $cacheCols;
            } else {
                for ($i = 0, $max = $rs->FieldCount(); $i < $max; $i++) {
                    $columns[] = $rs->FetchField($i);
                }
                $cacheRS = $cacheSig;
                $cacheCols = $columns;
                $rs->insertSig = $cacheSig++;
            }
            $recordSet = $rs;
        } else {
            printf(ADODB_BAD_RS, 'GetInsertSQL');
            return false;
        }
    }
    // Loop through all of the fields in the recordset
    foreach ($columns as $field) {
        $upperfname = strtoupper($field->name);
        if (adodb_key_exists($upperfname, $arrFields, $force)) {
            $bad = false;
            if (strpos($upperfname, ' ') !== false || $ADODB_QUOTE_FIELDNAMES) {
                switch ($ADODB_QUOTE_FIELDNAMES) {
                    case 'LOWER':
                        $fnameq = $zthis->nameQuote . strtolower($field->name) . $zthis->nameQuote;
                        break;
                    case 'NATIVE':
                        $fnameq = $zthis->nameQuote . $field->name . $zthis->nameQuote;
                        break;
                    case 'UPPER':
                    default:
                        $fnameq = $zthis->nameQuote . $upperfname . $zthis->nameQuote;
                        break;
                }
            } else {
                $fnameq = $upperfname;
            }
            $type = $recordSet->MetaType($field->type);
            /********************************************************/
            if (is_null($arrFields[$upperfname]) || empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0 || $arrFields[$upperfname] === $zthis->null2null) {
                switch ($force) {
                    case 0:
                        // we must always set null if missing
                        $bad = true;
                        break;
                    case 1:
                        $values .= "null, ";
                        break;
                    case 2:
                        //Set empty
                        $arrFields[$upperfname] = "";
                        $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields, $magicq);
                        break;
                    default:
                    case 3:
                        //Set the value that was given in array, so you can give both null and empty values
                        if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === $zthis->null2null) {
                            $values .= "null, ";
                        } else {
                            $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields, $magicq);
                        }
                        break;
//.........这里部分代码省略.........
开发者ID:spring,项目名称:spring-website,代码行数:101,代码来源:adodb-lib.inc.php

示例3: _GenFields

 function _GenFields($flds, $widespacing = false)
 {
     if (is_string($flds)) {
         $padding = '     ';
         $txt = $flds . $padding;
         $flds = array();
         $flds0 = Lens_ParseArgs($txt, ',');
         $hasparam = false;
         foreach ($flds0 as $f0) {
             $f1 = array();
             foreach ($f0 as $token) {
                 switch (strtoupper($token)) {
                     case 'CONSTRAINT':
                     case 'DEFAULT':
                         $hasparam = $token;
                         break;
                     default:
                         if ($hasparam) {
                             $f1[$hasparam] = $token;
                         } else {
                             $f1[] = $token;
                         }
                         $hasparam = false;
                         break;
                 }
             }
             $flds[] = $f1;
         }
     }
     $this->autoIncrement = false;
     $lines = array();
     $pkey = array();
     foreach ($flds as $fld) {
         $fld = _array_change_key_case($fld);
         $fname = false;
         $fdefault = false;
         $fautoinc = false;
         $ftype = false;
         $fsize = false;
         $fprec = false;
         $fprimary = false;
         $fnoquote = false;
         $fdefts = false;
         $fdefdate = false;
         $fconstraint = false;
         $fnotnull = false;
         $funsigned = false;
         //-----------------
         // Parse attributes
         foreach ($fld as $attr => $v) {
             if ($attr == 2 && is_numeric($v)) {
                 $attr = 'SIZE';
             } else {
                 if (is_numeric($attr) && $attr > 1 && !is_numeric($v)) {
                     $attr = strtoupper($v);
                 }
             }
             switch ($attr) {
                 case '0':
                 case 'NAME':
                     $fname = $v;
                     break;
                 case '1':
                 case 'TYPE':
                     $ty = $v;
                     $ftype = $this->ActualType(strtoupper($v));
                     break;
                 case 'SIZE':
                     $dotat = strpos($v, '.');
                     if ($dotat === false) {
                         $dotat = strpos($v, ',');
                     }
                     if ($dotat === false) {
                         $fsize = $v;
                     } else {
                         $fsize = substr($v, 0, $dotat);
                         $fprec = substr($v, $dotat + 1);
                     }
                     break;
                 case 'UNSIGNED':
                     $funsigned = true;
                     break;
                 case 'AUTOINCREMENT':
                 case 'AUTO':
                     $fautoinc = true;
                     $fnotnull = true;
                     break;
                 case 'KEY':
                 case 'PRIMARY':
                     $fprimary = $v;
                     $fnotnull = true;
                     break;
                 case 'DEF':
                 case 'DEFAULT':
                     $fdefault = $v;
                     break;
                 case 'NOTNULL':
                     $fnotnull = $v;
                     break;
                 case 'NOQUOTE':
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:flushcms,代码行数:101,代码来源:adodb-datadict.inc.php

示例4: _GenFields

 function _GenFields($flds)
 {
     $lines = array();
     $pkey = array();
     foreach ($flds as $fld) {
         $fld = _array_change_key_case($fld);
         $fname = false;
         $fdefault = false;
         $fautoinc = false;
         $ftype = false;
         $fsize = false;
         $fprec = false;
         $fprimary = false;
         $fnoquote = false;
         $fdefts = false;
         $fdefdate = false;
         $fconstraint = false;
         $fnotnull = false;
         //-----------------
         // Parse attributes
         foreach ($fld as $attr => $v) {
             if ($attr == 2 && is_numeric($v)) {
                 $attr = 'SIZE';
             } else {
                 if (is_numeric($attr) && $attr > 1 && !is_numeric($v)) {
                     $attr = strtoupper($v);
                 }
             }
             switch ($attr) {
                 case '0':
                 case 'NAME':
                     $fname = $v;
                     break;
                 case '1':
                 case 'TYPE':
                     $ty = $v;
                     $ftype = $this->ActualType(strtoupper($v));
                     break;
                 case 'SIZE':
                     $dotat = strpos($v, '.');
                     if ($dotat === false) {
                         $fsize = $v;
                     } else {
                         $fsize = substr($v, 0, $dotat);
                         $fprec = substr($v, $dotat + 1);
                     }
                     break;
                 case 'AUTOINCREMENT':
                 case 'AUTO':
                     $fautoinc = true;
                     $fnotnull = true;
                     break;
                 case 'KEY':
                 case 'PRIMARY':
                     $fprimary = $v;
                     $fnotnull = true;
                     break;
                 case 'DEFAULT':
                     $fdefault = $v;
                     break;
                 case 'NOTNULL':
                     $fnotnull = $v;
                     break;
                 case 'NOQUOTE':
                     $fnoquote = $v;
                     break;
                 case 'DEFDATE':
                     $fdefdate = $v;
                     break;
                 case 'DEFTIMESTAMP':
                     $fdefts = $v;
                     break;
                 case 'CONSTRAINT':
                     $fconstraint = $v;
                     break;
             }
             //switch
         }
         // foreach $fld
         //--------------------
         // VALIDATE FIELD INFO
         if (!strlen($fname)) {
             if ($this->debug) {
                 ADOConnection::outp("Undefined NAME");
             }
             return false;
         }
         if (!strlen($ftype)) {
             if ($this->debug) {
                 ADOConnection::outp("Undefined TYPE for field '{$fname}'");
             }
             return false;
         } else {
             $ftype = strtoupper($ftype);
         }
         $ftype = $this->_GetSize($ftype, $ty, $fsize, $fprec);
         if ($fprimary) {
             $pkey[] = $fname;
         }
         // some databases do not allow blobs to have defaults
//.........这里部分代码省略.........
开发者ID:jd5688,项目名称:amazon-search-engine,代码行数:101,代码来源:adodb-datadict.inc.php

示例5: _adodb_getinsertsql

function _adodb_getinsertsql(&$zthis, &$rs, $arrFields, $magicq = false)
{
    $values = '';
    $fields = '';
    $arrFields = _array_change_key_case($arrFields);
    if (!$rs) {
        printf(ADODB_BAD_RS, 'GetInsertSQL');
        return false;
    }
    $fieldInsertedCount = 0;
    // Get the table name from the existing query.
    preg_match("/FROM\\s+" . ADODB_TABLE_REGEX . "/i", $rs->sql, $tableName);
    // Loop through all of the fields in the recordset
    for ($i = 0, $max = $rs->FieldCount(); $i < $max; $i++) {
        // Get the field from the recordset
        $field = $rs->FetchField($i);
        // If the recordset field is one
        // of the fields passed in then process.
        $upperfname = strtoupper($field->name);
        if (isset($arrFields[$upperfname])) {
            // Set the counter for the number of fields that will be inserted.
            $fieldInsertedCount++;
            // Get the name of the fields to insert
            $fields .= $field->name . ", ";
            $mt = $rs->MetaType($field->type);
            // "mike" <mike@partner2partner.com> patch and "Ryan Bailey" <rebel@windriders.com>
            //PostgreSQL uses a 't' or 'f' and therefore needs to be processed as a string ('C') type field.
            if (strncmp($zthis->databaseType, "postgres", 8) === 0 && $mt == "L") {
                $mt = "C";
            }
            // Based on the datatype of the field
            // Format the value properly for the database
            if ($arrFields[$upperfname] === 'null') {
                $values .= "null, ";
            } else {
                switch ($mt) {
                    case "C":
                    case "X":
                    case 'B':
                        $values .= $zthis->qstr($arrFields[$upperfname], $magicq) . ", ";
                        break;
                    case "D":
                        $values .= $zthis->DBDate($arrFields[$upperfname]) . ", ";
                        break;
                    case "T":
                        $values .= $zthis->DBTimeStamp($arrFields[$upperfname]) . ", ";
                        break;
                    default:
                        $values .= (double) $arrFields[$upperfname] . ", ";
                        break;
                }
            }
        }
    }
    // If there were any inserted fields then build the rest of the insert query.
    if ($fieldInsertedCount > 0) {
        // Strip off the comma and space on the end of both the fields
        // and their values.
        $fields = substr($fields, 0, -2);
        $values = substr($values, 0, -2);
        // Append the fields and their values to the insert query.
        $insertSQL = "INSERT INTO " . $tableName[1] . " ( {$fields} ) VALUES ( {$values} )";
        return $insertSQL;
    } else {
        return false;
    }
}
开发者ID:jd5688,项目名称:amazon-search-engine,代码行数:67,代码来源:adodb-lib.inc.php

示例6: CreateTableSQL

 function CreateTableSQL($tabname, $flds, $tableoptions = false)
 {
     $sql = ADODB_DataDict::CreateTableSQL($tabname, $flds, $tableoptions);
     if (7.3 > (double) @$this->serverInfo['version']) {
         foreach ($flds as $fld) {
             $fld = _array_change_key_case($fld);
             $isAutoInc = false;
             foreach ($fld as $attr => $v) {
                 switch ($attr) {
                     case 'AUTOINCREMENT':
                     case 'AUTO':
                         $isAutoInc = true;
                         break;
                     case 'NAME':
                         $fname = $v;
                         break;
                 }
             }
             if (isset($fname) && $isAutoInc) {
                 // This field is an AUTOINCREMENT. Create a sequence
                 // for it.
                 $sequenceName = $this->makeObjectName($tabname, $fname, 'seq');
                 array_unshift($sql, "CREATE SEQUENCE {$sequenceName}");
                 array_push($sql, "ALTER TABLE {$tabname} ALTER COLUMN {$fname} SET DEFAULT nextval('{$sequenceName}')");
             }
         }
     }
     return $sql;
 }
开发者ID:ramonsodoma,项目名称:pkp-lib,代码行数:29,代码来源:datadict-postgres.inc.php

示例7: _adodb_getinsertsql

/**
 * There is a special case of this function for the oci8 driver.
 * The proper way to handle an insert w/ a blob in oracle requires
 * a returning clause with bind variables and a descriptor blob.
 * 
 * 
 */
function _adodb_getinsertsql(&$zthis, &$rs, $arrFields, $magicq = false, $forcenulls = false)
{
    $tableName = '';
    $values = '';
    $fields = '';
    $recordSet = null;
    $arrFields = _array_change_key_case($arrFields);
    $fieldInsertedCount = 0;
    if (is_string($rs)) {
        //ok we have a table name
        //try and get the column info ourself.
        $tableName = $rs;
        //we need an object for the recordSet
        //because we have to call MetaType.
        //php can't do a $rsclass::MetaType()
        $rsclass = $zthis->rsPrefix . $zthis->databaseType;
        $recordSet =& new $rsclass(-1, $zthis->fetchMode);
        $recordSet->connection =& $zthis;
        $columns = $zthis->MetaColumns($tableName);
    } else {
        if (is_subclass_of($rs, 'adorecordset')) {
            for ($i = 0, $max = $rs->FieldCount(); $i < $max; $i++) {
                $columns[] = $rs->FetchField($i);
            }
            $recordSet =& $rs;
        } else {
            printf(ADODB_BAD_RS, 'GetInsertSQL');
            return false;
        }
    }
    // Loop through all of the fields in the recordset
    foreach ($columns as $field) {
        $upperfname = strtoupper($field->name);
        if (adodb_key_exists($upperfname, $arrFields)) {
            // Set the counter for the number of fields that will be inserted.
            $fieldInsertedCount++;
            if (strpos($upperfname, ' ') !== false) {
                $fnameq = $zthis->nameQuote . $upperfname . $zthis->nameQuote;
            } else {
                $fnameq = $upperfname;
            }
            // Get the name of the fields to insert
            $fields .= $fnameq . ", ";
            $type = $recordSet->MetaType($field->type);
            if ($forcenulls && is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === 'null') {
                $values .= "null, ";
            } else {
                //we do this so each driver can customize the sql for
                //DB specific column types.
                //Oracle needs BLOB types to be handled with a returning clause
                //postgres has special needs as well
                $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields, $magicq);
            }
        }
    }
    // If there were any inserted fields then build the rest of the insert query.
    if ($fieldInsertedCount <= 0) {
        return false;
    }
    // Get the table name from the existing query.
    if (!$tableName) {
        preg_match("/FROM\\s+" . ADODB_TABLE_REGEX . "/is", $rs->sql, $tableName);
        $tableName = $tableName[1];
    }
    // Strip off the comma and space on the end of both the fields
    // and their values.
    $fields = substr($fields, 0, -2);
    $values = substr($values, 0, -2);
    // Append the fields and their values to the insert query.
    return 'INSERT INTO ' . $tableName . ' ( ' . $fields . ' ) VALUES ( ' . $values . ' )';
}
开发者ID:ahjo,项目名称:my-test-project,代码行数:78,代码来源:adodb-lib.inc.php


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