开发者

Creating CFArray from MySQL Result Array

开发者 https://www.devze.com 2022-12-15 12:47 出处:网络
Is there an easy way to dump an array returned from mysql_fetch_row into a CFArray? (part of the PHP implementation of CFPropertyList)

Is there an easy way to dump an array returned from mysql_fetch_row into a CFArray? (part of the PHP implementation of CFPropertyList) I'm bummed by the lack of documentation on CFPropertyList for PHP. Iterating through each item in the array seems inefficient. I'm open to using a different mysql_fetch_... command.

I'd like to just say:

$NewArray = new CFArray( $ResultArray )

But that deosn't seem to work.

This is my current code:

$plist = new CFPropertyList();
$ResultRow = mysqli_fetch_row( $result );
$plist->add( $TableRow = new CFArray() );

foreach ( $ResultRow as $Item ){
    $TableRow->add( new CFString( $Item ) )开发者_Go百科;
}


There are some new functions of CPPropertyList that should make this pretty easy. Namely CFTypeDetector. Here's a new version of the code in the question. (This code is untested).

$Plist = new CFPropertyList();
$TD = new CFTypeDetector();
while ( $ResultRow = mysqli_fetch_row($Result) ){ $GuessedStructure = $TD->toCFType( $ResultRow ); $Plist->add( $GuessedStructure ); }

0

精彩评论

暂无评论...
验证码 换一张
取 消