Way to get fields total
Is there a way to get total fields similar to total rows i.e. $Recordset->TotalRows?
I searched in rsobj.php and found mysqli_num_fields but can't figure out how to use it to grab total fields for a Recordset.
Is there a way to get total fields similar to total rows i.e. $Recordset->TotalRows?
I searched in rsobj.php and found mysqli_num_fields but can't figure out how to use it to grab total fields for a Recordset.
You just want a count?
It would be: sizeof($Recordset1->Columns);
I thought that would work but I get an error:
Warning</b>
: sizeof(): Parameter must be an array or an object that implements Countable in /nfs/c03/h02/mnt/51355/domains/test.lizmoore.com/html/test.php on line 133
I'm trying to adapt some the code below to create an xml file from a Recordset. I need it to work with MySQLi.
The line $totalColumns = sizeof($rsHoods->Columns); is where my current problem is. The original line was: $totalColumns=mysql_num_fields($rsHoods);
<?php
if (1==1) {
header("Content-type: text/xml");
header("Pragma: public");
header("Cache-control: private");
header("Expires: -1");
$export_rsHoods="";
if($export_rsHoods=="1"){
header("Content-Disposition: attachment; filename=recordset.xml");
header("Content-Type: application/force-download");
}
echo "";
echo "<recordset total=\"".$rsHoods->TotalRows."\">";
if($rsHoods->TotalRows > 0){
$Start_Record = 0;
$Num_Records = $rsHoods->TotalRows;
$Current_Record = 0;
if(isset($_POST['Start_Record']) && $_POST['Start_Record']!="" && isset($_POST['Num_Records']) && $_POST['Num_Records']!=""){
$Start_Record = $_POST['Start_Record'];
$Num_Records = $_POST['Num_Records'];
}
if(isset($_GET['Start_Record']) && $_GET['Start_Record']!="" && isset($_GET['Num_Records']) && $_GET['Num_Records']!=""){
$Start_Record = $_GET['Start_Record'];
$Num_Records = $_GET['Num_Records'];
}
$totalColumns = sizeof($rsHoods->Columns);
do{
if($Current_Record >= $Start_Record){
echo "<record>";
for ($x=0; $x<$totalColumns; $x++) {
$field = mysqli_fetch_field_direct($rsHoods, $x);
echo "<".$field."><"."![CD"."ATA[".$rsHoods->getColumnVal('$field')."]"."]></".$field.">";
}
echo "</record>";
}
$Current_Record=$Current_Record+1;
if($Current_Record-$Start_Record==$Num_Records){break;}
}while (!$rsHoods->atEnd());
}
echo "</recordset>";
die();
}
?>
What version of rsobj.php are you using?
Try this one. Reinstall the latest version of databridge to use this one automatically in future applications.
Almost there! What can I use to replace this line to get the current field name?
$field=mysql_field_name($rsHoods, $x);
I think I got that figured out:
$field = $rsHoods->Columns[$x]->name;
Got some questions about the differences between rsobj.php v2.27 and 2.38
$this->Debug = false; WHY FALSE?
$this->Prepared = true; WHY TRUE?
if ($paramValue === "" || $paramValue === NULL) $paramValue = $paramDefault;
What if I want a text variable to allow a blank value to be passed in order to match everything with a "contains" match?
Debug is set to false so that information can't be seen in errors that might include your database username or column names that a hacker could potentially use. It should always be set to false in a live environment and since most people wouldn't know where to change it after finishing development, it is defaulted to false.
Change it to true temporarily when you want to see more information about an error, but it should remain on false whenever in a production environment for security.
Prepared is set to true because it ensures SQL injection protection. There is SQL injection protection that I added when not using parameterized, but it is mine and not the built in MySQLi protection which is more tried and true. Setting it to true is actually probably a bit faster, but probably negligible unless you have a very high load on your server.
You can set a default for what to use when a parameter is blank. It has values like "WA_NULL", "WA_BLANK", "WA_ZERO", "WA_DEFAULT" or you can set it to a string. This just allows you to set a default other than blank when a blank value is entered. If the default is set to "WA_BLANK" then the blank value is maintained.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.