<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>ColumnResult constructor</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="class.mysql-xdevapi-columnresult.html">mysql_xdevapi\ColumnResult</a></div> <div class="next" style="text-align: right; float: right;"><a href="mysql-xdevapi-columnresult.getcharactersetname.html">ColumnResult::getCharacterSetName</a></div> <div class="up"><a href="class.mysql-xdevapi-columnresult.html">mysql_xdevapi\ColumnResult</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mysql-xdevapi-columnresult.construct" class="refentry"> <div class="refnamediv"> <h1 class="refname">ColumnResult::__construct</h1> <p class="verinfo">(No version information available, might only be in Git)</p><p class="refpurpose"><span class="refname">ColumnResult::__construct</span> — <span class="dc-title">ColumnResult constructor</span></p> </div> <div class="refsect1 description" id="refsect1-mysql-xdevapi-columnresult.construct-description"> <h3 class="title">Description</h3> <div class="constructorsynopsis dc-description"> <span class="modifier">private</span> <span class="methodname"><strong>mysql_xdevapi\ColumnResult::__construct</strong></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> Retrieve column metadata, such as its character set; this is instantiated by the RowResult::getColumns() method. </p> </div> <div class="refsect1 parameters" id="refsect1-mysql-xdevapi-columnresult.construct-parameters"> <h3 class="title">Parameters</h3> <p class="para">This function has no parameters.</p> </div> <div class="refsect1 examples" id="refsect1-mysql-xdevapi-columnresult.construct-examples"> <h3 class="title">Examples</h3> <div class="example" id="example-2025"> <p><strong>Example #1 <span class="function"><strong>mysql_xdevapi\ColumnResult::__construct()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$session </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_xdevapi</span><span style="color: #007700">\</span><span style="color: #0000BB">getSession</span><span style="color: #007700">(</span><span style="color: #DD0000">"mysqlx://user:password@localhost"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$session</span><span style="color: #007700">-></span><span style="color: #0000BB">sql</span><span style="color: #007700">(</span><span style="color: #DD0000">"DROP DATABASE IF EXISTS nonsense"</span><span style="color: #007700">)-></span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$session</span><span style="color: #007700">-></span><span style="color: #0000BB">sql</span><span style="color: #007700">(</span><span style="color: #DD0000">"CREATE DATABASE nonsense"</span><span style="color: #007700">)-></span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$session</span><span style="color: #007700">-></span><span style="color: #0000BB">sql</span><span style="color: #007700">(</span><span style="color: #DD0000">"CREATE TABLE nonsense.numbers (hello int, world float unsigned)"</span><span style="color: #007700">)-></span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$session</span><span style="color: #007700">-></span><span style="color: #0000BB">sql</span><span style="color: #007700">(</span><span style="color: #DD0000">"INSERT INTO nonsense.numbers values (42, 42)"</span><span style="color: #007700">)-></span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$schema </span><span style="color: #007700">= </span><span style="color: #0000BB">$session</span><span style="color: #007700">-></span><span style="color: #0000BB">getSchema</span><span style="color: #007700">(</span><span style="color: #DD0000">"nonsense"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$table </span><span style="color: #007700">= </span><span style="color: #0000BB">$schema</span><span style="color: #007700">-></span><span style="color: #0000BB">getTable</span><span style="color: #007700">(</span><span style="color: #DD0000">"numbers"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$result1 </span><span style="color: #007700">= </span><span style="color: #0000BB">$table</span><span style="color: #007700">-></span><span style="color: #0000BB">select</span><span style="color: #007700">(</span><span style="color: #DD0000">'hello'</span><span style="color: #007700">,</span><span style="color: #DD0000">'world'</span><span style="color: #007700">)-></span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">// Returns an array of ColumnResult objects<br /></span><span style="color: #0000BB">$columns </span><span style="color: #007700">= </span><span style="color: #0000BB">$result1</span><span style="color: #007700">-></span><span style="color: #0000BB">getColumns</span><span style="color: #007700">(); <br /><br />foreach (</span><span style="color: #0000BB">$columns </span><span style="color: #007700">as </span><span style="color: #0000BB">$column</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"\nColumn label " </span><span style="color: #007700">, </span><span style="color: #0000BB">$column</span><span style="color: #007700">-></span><span style="color: #0000BB">getColumnLabel</span><span style="color: #007700">();<br /> echo </span><span style="color: #DD0000">" is type " </span><span style="color: #007700">, </span><span style="color: #0000BB">$column</span><span style="color: #007700">-></span><span style="color: #0000BB">getType</span><span style="color: #007700">();<br /> echo </span><span style="color: #DD0000">" and is "</span><span style="color: #007700">, (</span><span style="color: #0000BB">$column</span><span style="color: #007700">-></span><span style="color: #0000BB">isNumberSigned</span><span style="color: #007700">() === </span><span style="color: #0000BB">0</span><span style="color: #007700">) ? </span><span style="color: #DD0000">"Unsigned." </span><span style="color: #007700">: </span><span style="color: #DD0000">"Signed."</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">// Alternatively<br /></span><span style="color: #0000BB">$result2 </span><span style="color: #007700">= </span><span style="color: #0000BB">$session</span><span style="color: #007700">-></span><span style="color: #0000BB">sql</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT * FROM nonsense.numbers"</span><span style="color: #007700">)-></span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">// Returns an array of FieldMetadata objects<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$result2</span><span style="color: #007700">-></span><span style="color: #0000BB">getColumns</span><span style="color: #007700">());</span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> Column label hello is type 19 and is Signed. Column label world is type 4 and is Unsigned. Array ( [0] => mysql_xdevapi\FieldMetadata Object ( [type] => 1 [type_name] => SINT [name] => hello [original_name] => hello [table] => numbers [original_table] => numbers [schema] => nonsense [catalog] => def [collation] => 0 [fractional_digits] => 0 [length] => 11 [flags] => 0 [content_type] => 0 ) [1] => mysql_xdevapi\FieldMetadata Object ( [type] => 6 [type_name] => FLOAT [name] => world [original_name] => world [table] => numbers [original_table] => numbers [schema] => nonsense [catalog] => def [collation] => 0 [fractional_digits] => 31 [length] => 12 [flags] => 1 [content_type] => 0 ) ) </pre></div> </div> </div> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="class.mysql-xdevapi-columnresult.html">mysql_xdevapi\ColumnResult</a></div> <div class="next" style="text-align: right; float: right;"><a href="mysql-xdevapi-columnresult.getcharactersetname.html">ColumnResult::getCharacterSetName</a></div> <div class="up"><a href="class.mysql-xdevapi-columnresult.html">mysql_xdevapi\ColumnResult</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>