array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'mysql-xdevapi-rowresult.fetchone.php', 1 => 'RowResult::fetchOne', ), 'up' => array ( 0 => 'class.mysql-xdevapi-rowresult.php', 1 => 'mysql_xdevapi\\RowResult', ), 'prev' => array ( 0 => 'mysql-xdevapi-rowresult.fetchall.php', 1 => 'RowResult::fetchAll', ), 'next' => array ( 0 => 'mysql-xdevapi-rowresult.getcolumncount.php', 1 => 'RowResult::getColumnsCount', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/mysql_xdevapi/mysql_xdevapi/rowresult/fetchone.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(No version information available, might only be in Git)
RowResult::fetchOne — 結果セットから行を取得する
結果セットから一行取得します。
この関数は、 現在のところ詳細な情報はありません。引数のリストのみが 記述されています。
この関数にはパラメータはありません。
結果を連想配列として返します。
結果が存在しない場合は null
を返します。
例1 mysql_xdevapi\RowResult::fetchOne() の例
<?php
$session = mysql_xdevapi\getSession("mysqlx://user:password@localhost");
$session->sql("DROP DATABASE addressbook")->execute();
$session->sql("CREATE DATABASE addressbook")->execute();
$session->sql("CREATE TABLE addressbook.names(name text, age int)")->execute();
$session->sql("INSERT INTO addressbook.names values ('John', 42), ('Sam', 33)")->execute();
$schema = $session->getSchema("addressbook");
$table = $schema->getTable("names");
$row = $table->select('name', 'age')->where('age < 40')->execute()->fetchOne();
print_r($row);
上の例の出力は、 たとえば以下のようになります。
Array ( [name] => Sam [age] => 33 )