I would like to be able to get the ID of my record in my sql statement:
$result = $db->query("select id,FQDN, ip_address, .....");
However, I don't want it to show up in the export using headings:
$headings = array('Name (FQDN)','Management IP Address', ......");
Is it possible to hide the ID value?
Thanks
Columns or rows can be set to "HIDDEN"
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
will hide column C
or
$objPHPExcel->getActiveSheet()->getRowDimension(5)->setVisible(false);
will hide row 5
Related
I have SSRS report parameter name "Status" which contains Passed and Failed values. In the report I have one column called Name. I want to hide this column when Status = "Failed" and I want to show this column when Status = "Passed" or Status = "Passed,Failed".
=IIF(InStr(JOIN(Parameters!Status.Value,","), "Failed"),True,False)
Above expression hide the Name column for when Status = "Passed,Failed".
You should be able to do this .. but with the join, you may not need the / ToString() bit
=IIF((JOIN(Parameters!Status.Value,",").ToString().Contains("Failed"),"True","False")
Alternative:
=IIf(InStr(JOIN(Parameters!Status.Value,",").ToString(),"Failed") > 0,"True","False")
How about this:
=String.Join(",", Parameters!Status.Label).Contains("Failed")
I am showing data in CGridView from a dynamic SQL Query using CSqlDataProvider. There are some static and some dynamic column. Now I want to do some special formatting like currency in the dynamic columns. But how do I do that when I don't know the number/name of the columns till the query is executed.
Also i want to be able to sort the dynamic columns and again I have the same problem that I don't have all the column names.
Anyone before who worked with dynamic queries and gridview. Could please point me to the right direction or give some ideas how to do it.
In short I am able to successfully show the data in gridview(also dynamic rows) and sort all the static columns. Just need to sort dynamic rows and format dynamic & static columns
Code for GridView:
$tdata=$dataProvider->getData();
//Calculation to get column names
$grid_columns = array_keys($tdata[0]);
foreach($grid_columns as $i=>$ii)
{
//Applying Formula to get Total Row
$grid_final[$i] = array('name'=>$ii,'class'=>'bootstrap.widgets.TbTotalSumColumn');
}
//Grid View
$this->widget('bootstrap.widgets.TbExtendedGridView', array(
'sortableRows'=>true,
'afterSortableUpdate' => 'js:function(id, position){ console.log("id: "+id+", position:"+position);}',
'dataProvider'=>$dataProvider,
'type'=>'striped bordered',
'template' => "{items}\n{extendedSummary}",
'columns'=> $grid_final,
));
Controller Code:
public function actionIndex()
{
if(isset($_GET['month']))
{
$month=$_GET['month'];
}
else
{
$month= 7;
}
//SQL Query with Dynamic Columns
$sql = "SELECt ABC,X,Y,Z, #Column_Names
FROM some_table
WHERE [month] = :month";
$connection=Yii::app()->db;
$command=$connection->createCommand($sql);
$command->bindParam(':month',$month,PDO::PARAM_STR);
$dataProvider=new CSqlDataProvider($sql,array('keyField' => 'ABC','params' => array(
':month' => $month,
),'sort' => array(
//Here how do i put column names which i don't know yet for sorting
'attributes' => array(
'ABC','X','Y','Z' )),'pagination'=>false));
$this->render('index',array('dataProvider' => $dataProvider, 'month' => $month));
}
I create dynamic columns in Yii like this:
In some_table model, let's name it SomeTable, I declare a maximum number of column names like this:
public $column1, $column2, $column3, $column4;
I create a function in that model, let's name it 'search()' that builds the dataProvider, like your logic states, but I make sure that #Column_Names looks like something like this:
var_column1 as column1, var_column2 as column2, etc.
in validation(), declare all those columns as safe on 'search'
construct a columns array formed from merging model->attributes and all declared columns with their options and assign it to the view, exactly like you do with $grid_final variable
The only drawback here is that you need to know the maximum number of columns, and of course, the big problem of declaring allot of variables if you have tables with allot of columns.
If you are able to get the columns before the grid is rendered, you can also alter the sorting conditions of the dataprovider.
Something like this:
$tdata=$dataProvider->getData();
//Calculation to get column names
$grid_columns = array_keys($tdata[0]);
$dataProvider->setSort(array('attributes'=> $grid_columns));
Or you can of course prepare you own array of attributes with specific settings, or specific formatting according to any logic you have. The thing is - once you have the columns in $grid_columns you can alter the dataProvider sorting, or the gridColumn setting as you need.
I can limit the size of characters of table field in mysql as simple
SELECT NID,LEFT(BODY, 10) AS text FROM tablename
but how can i get the same result in codeigniter Active Record
I tried this code
$this->db->select('NID, LEFT(BODY,10)');
$query = $this->db->get_where('tablename');
but not working
is it possible to make that in codeigniter Active Record ??
I've been able make it work in Codeigniter using a syntax like this:
$this->db->select('NID, LEFT(BODY,10) BODY', false);
$query = $this->db->get_where('tablename');
as stated in: http://ellislab.com/forums/viewthread/201014/#940615
adding 'false' to select, avoids the automatic backtics
also, after left(BODY, 10), you must add the name the new chopped field will use:
select('NID, LEFT(BODY,10) BODY'
otherwise, Codeigniter will output an Undefined property error.
I hope it works!
I'm trying to create an app using Titanium Studio that will display information from an SQLite database.
To make things simpler, lets say my database have the following columns:
Last Name, Given Name, Age, Race & Religion
I currently have a basic framework for the app, which consists of multiple tabs.
In one of the tabs (which corresponds to a particular window), I would like to have a TableView that displays only Last Name, Given Name & Age in each row.
How do I do that?
Appreciate all the help I can get!
Thanks!
Have you looked at this?
So once you get the rows from the database, just create rows for your tableview. Here is a start:
// Fetch the db and execute a select from your person table
var db = Ti.Database.open('mydb');
var rows = db.execute('SELECT * FROM person');
var persons = [];
while (rows.isValidRow())
{
persons.push({title : + rows.fieldByName('Last Name'));
rows.next();
};
rows.close();
var yourTable = Ti.UI.createTableView({
width : Ti.UI.FILL,
height : Ti.UI.FILL,
data: persons // Set the rows to the table
});
// Dont forget to close the db
db.close();
Use this as a reference to style your table rows more effectively.
I have table called wp_email_subscription and inside table I have rows of emails from subscribed users. Each row contains id, email, and name column.
I have also created admin page for plugin where I would like to list all emails from subscribed table.
Basically I don't know how to use wpdb functions, I have read wpdb instructions from wp website but I don't understand.
what I need is to select all from wp_email_subscription and foreach row to display email and name column in list.
you have to use global wpdp variable and get_result function in your code page like this...
global $wpdb;
$row = $wpdb->get_results( "SELECT * FROM wp_email_subscription");
foreach ( $row as $row )
{ echo "email:".$row->email.";} //$row->your_column_name in table
like this, you can access all columns by $variable->col_name