2sxc - add new record to non 2sxc data table - dotnetnuke

I know that this is more dnn than 2sxc question but I have some custom table inside dnn database and don't know how to do clasic dnn modules and using only 2sxc for module development.
My question is if you can give me some guides what is the easyest way for adding new record in this table from razor script or 2sxc apicontroller (preferred).
It would be the best if someone can paste some sample with code to get sql connection string, dnn database object qualifier and sql with command execution.
I don't need any relationship stuf.
From there I think that I can figured out how to make also edit and delete and post code back that others can see.
I don't plan to use this for many stuf but we have some sensors and aplication with a lotoff events and need custom table I can easy clear and index, and don't want that this data is EAV tabels.
For later I know how to get data back for visualization over sql datasource inside 2sxc.

In the far future we'll create a generic API to store to any kind of repository (EAV, SQL, CSV, Json, etc.) but for now, you'll just have to code it.
Basically your question isn't actually related to 2sxc - I recommend you simply google things like "save data to SQL using WebApi" or something - then put this code into an API controller in 2sxc.
At the moment I don't have any demo-code, but if you do create a demo, I would be glad to blog about it and publish in on https://2sxc.org/en/apps

Related

Best approach to get notifications from database when table record changing in asp.net core web api

I'm working with asp.net-core 2.2 web api project with angular 7. In this I want to get notifications when a record inserting or updating in specific table. I read many of articles on it with sqldependancy class. But none of them didn't give me any satisfied answer. The thing I want to know is, are there any best approaches to do this work with another way. And if the best approach is,using sqldependecy how to combine it with EntityFramework core?
You could create an AFTER UPDATE TRIGGER on the table. Depending on how you want to get notified (SQL Mail for example) you could then code for it.
(on a personal note, I hate triggers but this is another way to do it)

Laravel - Migrate database from other frameworks

I was working on a project which is already advanced, specially the database, that has been filled by someone from my team, even though part of it has not been used yet. Some tables can be emptied and refilled as it's sample data, however most of them contains data which will be actually used or it's been used in the parts we're doing now.
The project started in CodeIgniter, by we've realized that Laravel can save us hours of work, so we're planning to migrate it. The point is that we didn't use the CodeIgniter's migration system, and we've seen in the Laravel documentation that only the table structure will be migrated, plus we have to create every migration.
The question here is if there's a way to both, create the migratinos files automatically, and to keep the relevant data that will be used in the application so we don't need to refill the database again (yep, there are kind of big tables). We thought on the seeders, but what we've seen is that they only store sample data...
You can use Laravel migration generator. It will simply help you to generate migrations from your
existing database. Check it out below. You will find in readme how to use it. Good luck.
https://github.com/Xethron/migrations-generator
Hope , it helps. Thanks. Cheers. -_-

Change Implementation of Select, Update, and Insert in SQL Server

To give you the question first: I want to know if it is possible to create a stored procedure or something in SQL Server that intercepts and translates SELECT, INSERT, and UPDATE commands. Now for the explanation:
I am writing a web application to replace an old desktop app. Its a business app which is basically a database interface with reports and searches and all the good ol' CRUD. The new and old apps need to live in harmony together since some customers may be using the old and new together to access the same DB.
My problem is that the original database format stores most data in a single blob of text (1 nvarchar(MAX) field). I want to add functionality to search on fields stored in the blob, but it will be cumbersome and slow. I would like to update the database format without changing the desktop app at all, hence the question above.
It occurs to me that I could do this on the client by writing a wrapper class for the data access object and then do a bulk replace in the client code to reference the wrapper, but I want to know what my options are on the server as well.
In case anyone wants to know, the old app is in VB6 and the new in C#.
EDIT
Alright, so it looks like if I do anything on the server side we are looking at adding stored procedures and then updating the client VB6 code to reference the stored procs. Do something like a bulk replace of SELECT with sp_oldselect ... To return the data in a different format. I'm guessing a client-side wrapper would be the best solution for the time-being. Old apps die hard.
You can create a bunch of views for the old client and let it to query those views. It will be slow as hell in most cases, but it can 'replace' the select query. For updates and insert.. well.. instead of triggers on the views could help is some cases, but it will require lots of processing.
However my suggestion is to provide exactly the same functionality in the web app and deprecate the desktop app. When the desktop app's share is low enough, stop supporting it. From this point, you are (mostly) free to add new functions, upgrade the database schema, etc.
I agree with JonH, that alot can go wrong here, but you can try and read up on the INSTEAD OF Triggers in MS SQL server here: https://technet.microsoft.com/en-us/library/ms179288(v=sql.105).aspx

how to display database data in joomla

I am new to joomlah . So far I have acomplished the following :
1. I have installed it on wamp server.
2. I have created a fewe articles.
3. I have created another schema on the database that comes with a wamp.
Now, I need to do two things and I wonder what is the best practice
1. Create a template article that will display data in a format
2. Load the data from the DB.
Since a lot of the answers to this question refer to older versions or 2009 answers
I wonder what is the reccomended way to do it today.
(Should I do it with PHP? is there a recommended pluggin? )
Thanks
You have 2 choices either:
Using this tutorial create a custom component (components are the extension type responsible for displaying content in Joomla's main area)
Look through the Joomla! Extension Directory (JED) for an existing solution - probably start with the "Tables & Lists" category.
I have used Table JX extension for a few years now. It is commercial, though but I think it is worth its money. It has a pretty simple user interface and you can do the basic stuff like to show a database table in an article just by clicking.
Their webpage is not the best, but the demo is quite informative: http://www.toolsjx.com/table-jx/demo

Is it possible to query the Magento database and display product attributes outside Magento?

I am building a site that needs to display some product info from a Magento Database, but display it on another page/site outside the Magento intallation. I know the information gets displayed twice, but I would like the site to avoid content duplication and pull that same info from an only source, the Magento product database.
Is this posible? Has anyone done it?
What would be a lot easier to do would be to pull in the entire Magento engine into your external page. This [unlike the rest of Magento] is pretty easy to do.
All you have to do is the following:
// Load Up Magento Core
define('MAGENTO', realpath('/var/www/magento/'));
require_once(MAGENTO . '/app/Mage.php');
$app = Mage::app();
Now you can use any of the Magento objects/classes as if you were inside of Magento and get your attributes
$product = Mage::getModel('catalog/product')->load(1234);
$product->getSku();
$product->getYourCustomAttribute();
etc etc.
Yes, I've done it a few ways. The safest way to do this is using the webservices Magento exposes to query objects programmatically. This will insulate you from database-level changes (such as the flat product catalog, a recent addition).
Failing that (if the performance of the webservices doesn't meet your needs), you can reconstruct the catalog data from the database directly. Use the following tables (assuming you're not using the flat catalog):
eav_entity_type
eav_attribute
catalog_product_entity
catalog_product_entity_int
catalog_product_entity_varchar
catalog_product_entity_text
catalog_product_entity_decimal
catalog_product_entity_datetime
You'll want to read up on EAV models before you attempt this. Bear in mind that this is largely the topic over which people call Magento complicated.
Hope that helps!
Thanks,
Joe

Resources