making a global variable and incrementing in function - CodeIgniter - codeigniter

I'm trying to make a global variable in my model to increment an id field in my mysql table, but CI won't allow me to make global variables.
I've searched around and people are mentioning having to create a library and declaring the global variable there, and then loading the library in the model and using the variable.
I understand that approach, but how/where would I be able to increment the variables value so that the next time it's called in a function it will be +1?
Thank you in advance for any help
edit: the thing I'm trying to do is whenever I insert a new row in a table, I want to continue on from the last entries id number i.e. last id number in the table is 9, I want to increment on from that number and make the new rows id number 10

If you're able to access the database through CI you can use the Active Record count_all() function.
From CI docs http://ellislab.com/codeigniter/user-guide/database/active_record.html
Permits you to determine the number of rows in a particular table.
Submit the table name in the first parameter. Example:
echo $this->db->count_all('my_table');
// Produces an integer, like 25
You would just get the number of rows in the table returned and add 1 for the row in your new entry.

Related

how to fetch previous values of a table in oracle forms

My first task is to add two new columns to a table, first column stores the values of M and X fields values in a single column(as a single unit with a pipe separator) and second column stores O and Z fields values in a single column(as a single unit with a pipe separator).
second task selecting agency and external letter rating(shown in image) from drop down and after saving the form the value from fields M and X should move to N and Y and this values should be stored in table column that are created from task one, Now if we save the form the values should move to O and Z fields in forms and this should continue.
Can any one help me how to proceed with this and I don't know how to separate a column value into pieces and display on form.
Better if you propose any new method that does the same work.
Adding columns:
That's a bad idea. Concatenating values is easy; storing them into a column as well. But, then - in the next step - you have to split those values into two values (columns? rows?) to be joined to another value and produce result. Can you do it? Sure. Should you? No.
What to do? If you want to store 4 values, then add 4 columns to a table.
Alternatively, see if you can create a master-detail relationship between two tables so you'd actually create a new table (with a foreign key to existing table) with two additional columns:
one that says is value stored related to M or Y
value itself
It looks like more job to do, but - should pay off in the future.
Layout:
That really looks like a tabular form, which only supports what I previously said. You can't "dynamically" add rows (or, even if you could, that's really something you should avoid because you'd have to add (actually, display) separate items (not rows that share the same item name).

Laravel count data field in table row

I have one table that has many fields,
Is it possible to count how many fields that filled?
I tried count() but seems doesnt work correctly, it only count the rows of the table
The purpose is i want to take the percentage of each student's completed task
This is the view from the page
This is the table
I think your table structure is messy.
why not, setup a one to many relation instead of doing that.
https://laravel.com/docs/8.x/eloquent-relationships#one-to-many-inverse
I would also suggest you use increment, every new task completed you increment the value. Please refer to this https://laravel.com/docs/8.x/queries.

How to get value from a specific row and column in MS ACCESS database?

First, I don't have unique value to directly point out a value I want to retrieve, so there for, I cannot use the WHERE Statement. The reason for that, because I have a database where I constantly updated or deleted, so if I use WHERE statement I have to edit the code again.
Then do apply a unique value - add a field of data type AutoNumber or you will never get out of this mess.

biztalk 2010 table looping functoid not working

I have a flat file that I'm trying to transform into X12_00401_820. When I use the table looping and table extractor, the loop never happens.
Below is my map:
Below is the output. The invoice numbers are looping right, but I'm only getting the first amount, not the amount for each invoice.
The first input parameter to this functoid must be a scoping link, and
the second represents the number of columns in the data grid.
The first parameter of your functoid is the scope, you have to set your scope to SellersInvoiceNumber (don't link it graphically just write in input[0] SellersInvoiceNumber )
The second parameter of your functoid is the number of columns, you have to put 2 there as you will have two columns in your grid
So the third and fourth parameters will be your SellersInvoiceNumber and Invoice amount field (link it graphically as you already did)
Don't forget to configure your columns in the Table Looping Grid but i guess you've already done that
This should work

How to find maximum Value in JDE (RDA)

I would like to knew how can I find the maximum value in column in JDE Solution? Would you mind to show me the way to do it? Because I am not able to do it by using JDE RDA.
What do you mean by:
..i not able to do it by using JDE RDA..
You don't know how to use it or you're using the FDA?
Well, in RDA you can use the Aggregate Maximum Of, doing a Level Break on the column you want the maximum value.
On FDA you need to code your logic, something like:
MaxValue = 0
Begin Loop through the table
If table.column_you_want > MaxValue
MaxValue = table.column_you_want
End If
End Loop
Depending on your needs, if you are looking to find the next available ID to use in your table, there is already a concept well implemented in JDE to keep track of the next unique id for a table or even a process.
Unique id for a table
Look at the program P00022 which hold a next number by table. There is the business function X00022 you can use in your report to retrieve the value.
Unique ID for a process
Look at the program P0002 which holds next numbers by modules for specific document type. Use the business function X0002 to access the values in your RDA.

Resources