Search Results

Search found 1973 results on 79 pages for 'orm profiler'.

Page 7/79 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Codeigniter php activerecord orm limit and offset

    - by user2167174
    I am a bit stuck with this problem I have in phpactiverecord. What I am trying to do is a pagination so I need to limit and offset the query results. I am accessing all of the user posts like so: $user-post; How can I query this to limit and offset the results? Thanx in advance. Code: public function office() { if (!$this->session->userdata('username')) { redirect(base_url()); } $data = array(); $data['posts'] = []; $user = User::find('first', array('id' => $this->session->userdata('id'))); if ($user != null) { if ($user->post != null) { foreach ($user->post as $post) { $posts = array($post->name, $post->description, $post->date,'<a href="'.base_url().'Posts/edit/'.$post->id.'">Edit</a> <br /><a href="'.base_url().'Posts/delete/'.$post->id.'">Delete</a>'); array_push($data['posts'], $posts); } $this->table->set_heading('Name', 'Description', 'Date', '<a href="'.base_url().'Posts/create">+Add</a>'); $tmpl = array('table_open' => '<table class="table table-stripped table-bordered user-posts">'); $this->table->set_template($tmpl); $data['table'] = $this->table->generate($data['posts']); } $this->load->view('template/header.php'); $this->load->view('Users/office.php', $data); $this->load->view('template/footer.php'); } else { redirect(base_url()); } }

    Read the article

  • How to dynamically change fields in an .NET ORM

    - by rsteckly
    I'm working in ASP.NET in an application where often users want to add fields or change field names. I'd like to be able to have an xml schema in place that is parsed and a dynamic object model created from it that can be accessed throughout the application. My initial reaction is that this is not realistic. I think there is flexibility about the dynamic nature of it. I think the people I'm trying to build this for wouldn't mind recompiling. Even if the app recompiled, I don't know how to abstract away enough in my code access the data to allow for users changing property names, etc. How can you write LINQ when the properties might change? In short, there's two questions here: 1) is there a way to dynamically generate an object model of the database and 2) is there a way to abstract away enough so that code accessing the database doesn't break when properties change?

    Read the article

  • PHP ORM's, multiple tables and efficiency

    - by sunwukung
    Let's say I have a data mapper function that aggregates multiple tables and generates an object instance from that data. The mapper has a typical save() method which delegates to update/insert. When the mapper executes save - ideally it isolates object fields that have been modified, thus preventing the code from blanket bombing the database. How would you go about this?

    Read the article

  • ORM Against a Service-Wrapped Data Source

    - by blaster
    We are tasked with migrating an existing set of entities (currently POCOs persisted with NHibernate against an MSSQL database) to now persist to some kind of web service (yet to be built, either RESTful or SOAP-based, and that we control). I like how NHibernate encapsulates the persistence concerns and lets us maintain a logic-rich, persistence-agnostic domain model. Is there any way to make NHibernate talk to a web service at the back end instead of a SQL database directly? In other words, can "service instead of SQL database" be treated as a persistence implementation detail and allow us to continue to use NHibernate? Am I asking the right question? :)

    Read the article

  • Define classes for a datatable structure - ORM

    - by user424493
    I have existing tables - I have following datatables : ActivityTable(Key ActivityId) - which lists the identifier for various activity ProcessTable (identified by ProcessId) - which lists down which activites(ActivityId) are to be carried out along with their order(StepNum). Some of the activities are marked constant with in a process, that is they will have same data, ir-respective of there run environment. RunTable(Key RunConfigurationId) - that identifies the project name and Process Id Then data for each activity is stored is stored in their individual tables Activity_A, Activity_B,Activity_C so on it uses a combination of RunConfigurationId,ProcessId and stepNum. For the activities which are constant we use a RunConfigurationId= -100. Can anybody help me out how I can map something like this in classes using inheritence regards

    Read the article

  • Testing with Profiler Custom Events and Database Snapshots

    We've all had them. One of those stored procedures that is huge and contains complex business logic which may or may not be executed. These procedures make it an absolute nightmare when it comes to debugging problems because they're so complex and have so many logic offshoots that it's very easy to get lost when you're trying to determine the path that the procedure code took when it ran. Fortunately Profiler lets you define custom events that you can raise in your code and capture in a trace so you get a better window into the sub events occurring in your code. I found it very useful to use custom events and a database snapshot to debug some code recently and we'll explore both in this article. I find raising these events and running Profiler to be very useful for testing my stored procedures on my own as well as when my code is going through official testing and user acceptance. It's a simple approach and a great way to catch any performance problems or logic errors.

    Read the article

  • Django Querying Relation of Relation

    - by Brent
    I'm stuck on a Django ORM issue that is bugging me. I have a set of models linked by a foreign key but the requirements are a bit odd. I need to list items by their relation's relation. This is hard to explain so I've tried to depict this below, given: Work ManyToMany(Award) Award ForeignKey(AwardCategory) AwardCategory I need to list work items so they are listed by the award category. Desired output would be: Work Instance A Award Instance A that belongs to Award Category Instance A Award Instance C that belongs to Award Category Instance A Award Instance G that belongs to Award Category Instance A Work Instance A (same instance as above, but listed by different award__category) Award Instance F that belongs to Award Category Instance B Award Instance R that belongs to Award Category Instance B Award Instance Z that belongs to Award Category Instance B Work Instance B Award Instance B that belongs to Award Category Instance A Award Instance A that belongs to Award Category Instance A Essentially I want to list all work by the award category. I can get this to work in part but my solution is filthy and gross. I'm wondering if there is a better way. I considered using a ManyToMany and a through attribute but I'm not certain if I'm utilizing it correctly.

    Read the article

  • Is inline SQL still classed as bad practice now that we have Micro ORMs?

    - by Grofit
    This is a bit of an open ended question but I wanted some opinions, as I grew up in a world where inline SQL scripts were the norm, then we were all made very aware of SQL injection based issues, and how fragile the sql was when doing string manipulations all over the place. Then came the dawn of the ORM where you were explaining the query to the ORM and letting it generate its own SQL, which in a lot of cases was not optimal but was safe and easy. Another good thing about ORMs or database abstraction layers were that the SQL was generated with its database engine in mind, so I could use Hibernate/Nhibernate with MSSQL, MYSQL and my code never changed it was just a configuration detail. Now fast forward to current day, where Micro ORMs seem to be winning over more developers I was wondering why we have seemingly taken a U-Turn on the whole in-line sql subject. I must admit I do like the idea of no ORM config files and being able to write my query in a more optimal manner but it feels like I am opening myself back up to the old vulnerabilities such as SQL injection and I am also tying myself to one database engine so if I want my software to support multiple database engines I would need to do some more string hackery which seems to then start to make code unreadable and more fragile. (Just before someone mentions it I know you can use parameter based arguments with most micro orms which offers protection in most cases from sql injection) So what are peoples opinions on this sort of thing? I am using Dapper as my Micro ORM in this instance and NHibernate as my regular ORM in this scenario, however most in each field are quite similar. What I term as inline sql is SQL strings within source code. There used to be design debates over SQL strings in source code detracting from the fundamental intent of the logic, which is why statically typed linq style queries became so popular its still just 1 language, but with lets say C# and Sql in one page you have 2 languages intermingled in your raw source code now. Just to clarify, the SQL injection is just one of the known issues with using sql strings, I already mention you can stop this from happening with parameter based queries, however I highlight other issues with having SQL queries ingrained in your source code, such as the lack of DB Vendor abstraction as well as losing any level of compile time error capturing on string based queries, these are all issues which we managed to side step with the dawn of ORMs with their higher level querying functionality, such as HQL or LINQ etc (not all of the issues but most of them). So I am less focused on the individual highlighted issues and more the bigger picture of is it now becoming more acceptable to have SQL strings directly in your source code again, as most Micro ORMs use this mechanism. Here is a similar question which has a few different view points, although is more about the inline sql without the micro orm context: http://stackoverflow.com/questions/5303746/is-inline-sql-hard-coding

    Read the article

  • Data Access Objects old fashioned? [on hold]

    - by Bono
    A couple of weeks ago I delivered some work for a university project. After a code review with some teachers I got some snarky remarks about the fact that I was (still) using Data Access Objects. The teacher in question who said this mentions the use of DAO's in his classes and always says something along the lines of "Back then we always used DAO's". He's a big fan of Object Relational Mapping, which I also think is a great tool. When I was talking about this with some of my fellow students, they also mentioned that they prefer the use of ORM, which I can understand. It did make me wonder though, is using DAO's really so old fashioned? I know that at my work DAO's are still being used, but this is due to the fact that some of the code is rather old and therefor can't be coupled with ORM. We also do use ORM at my work. Trying to find some more information on Google or Stack Exchange sites didn't really enlighten me. Should I step away from the use of DAO's and only start implementing ORM? I just feel that ORM's can be a bit overkill for some simple projects. I'd love to hear your opinions (or facts) about this.

    Read the article

  • Kohana 3 ORM: How to get data from pivot table? and all other tables for that matter

    - by zenna
    I am trying to use ORM to access data stored, in three mysql tables 'users', 'items', and a pivot table for the many-many relationship: 'user_item' I followed the guidance from http://stackoverflow.com/questions/1946357/kohana-3-orm-read-additional-columns-in-pivot-tables and tried $user = ORM::factory('user',1); $user->items->find_all(); $user_item = ORM::factory('user_item', array('user_id' => $user, 'item_id' => $user->items)); if ($user_item->loaded()) { foreach ($user_item as $pivot) { print_r($pivot); } } But I get the SQL error: "Unknown column 'user_item.id' in 'order clause' [ SELECT user_item.* FROM user_item WHERE user_id = '1' AND item_id = '' ORDER BY user_item.id ASC LIMIT 1 ]" Which is clearly erroneous because Kohana is trying to order the elements by a column which doesn't exist: user_item.id. This id doesnt exist because the primary keys of this pivot table are the foreign keys of the two other tables, 'users' and 'items'. Trying to use: $user_item = ORM::factory('user_item', array('user_id' => $user, 'item_id' => $user->items)) ->order_by('item_id', 'ASC'); Makes no difference, as it seems the order_by() or any sql queries are ignored if the second argument of the factory is given. Another obvious error with that query is that the item_id = '', when it should contain all the elements. So my question is how can I get access to the data stored in the pivot table, and actually how can I get access to the all items held by a particular user as I even had problems with that? Thanks

    Read the article

  • How do I relate tables with different foreign key names in Kohana ORM?

    - by Matt H
    I'm building a Kohaha application to manage sip lines in asterisk. I'm wanting to use ORM but I'm wondering how do relate certain tables that are already well established. e.g. the table sip_lines looks like this. +--------------------+------------------+------+-----+-------------------+-----------------------------+ | Field | Type | Null | Key | Default | Extra | +--------------------+------------------+------+-----+-------------------+-----------------------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | sip_name | varchar(80) | NO | UNI | NULL | | | displayname | varchar(48) | NO | | NULL | | | line_num | varchar(10) | NO | MUL | NULL | | | model | varchar(12) | NO | MUL | NULL | | | mac | varchar(16) | NO | MUL | NULL | | | areacode | varchar(6) | NO | MUL | NULL | | | per_line_astpp_acc | tinyint(1) | NO | | 0 | | | play_warning | tinyint(1) | NO | | 0 | | | callout_disabled | tinyint(1) | NO | | 0 | | | notes | varchar(80) | NO | | NULL | | | last_update | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | +--------------------+------------------+------+-----+-------------------+-----------------------------+ sip_buddies is this: +----------------+------------------------------+------+-----+-----------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+------------------------------+------+-----+-----------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(80) | NO | UNI | | | | host | varchar(31) | NO | | | | | | | lastms | int(11) | NO | | 0 *** snip *** +----------------+------------------------------+------+-----+-----------+----------------+ The two tables are actually related as sip_lines.sip_name = sip_buddies.name How do I relate them in Kohana ORM as this wouldn't be quite right would it? <?php defined('SYSPATH') or die('No direct script access.'); /* A model for all the account information */ class Sip_Line_Model extends ORM { protected $has_one = array("sip_buddies"); } ?> EDIT: Actually, it'd be fair to say that these tables are not properly related with foreign keys! doh. EDIT: Looks like Kohana ORM is not that flexible. ORM is probably not the way to go and works best for completely new projects where the data model can be altered. The reason being that the key names must follow a specific naming convention or else they won't relate in Kohana.

    Read the article

  • Is ORM (Linq, Hibernate...) really that useful?

    - by Peter
    I have been playing with some LINQ ORM (LINQ directly to SQL) and I have to admit I like its expressive powers . For small utility-like apps, It also works quite fast: dropping a SQL server on some surface and you're set to linq away. For larger apps however, the DAL never was that big of an issue to me to setup, nor maintain, and more often than not, once it was set, all the programming was not happening there anyway... My, honest - I am an ORM newbie - question : what is the big advantage of ORM over writing a decent DAL by hand? (seems like a double, couldn't find it though) UPDATE : OK its a double :-) I found it myself eventually : ORM vs Handcoded Data Access Layer

    Read the article

  • LINQ to SQL Profiler

    In this article we will be taking a look at the new LINQ to SQL Profiler from HibernatingRhinos. This tool gives you a view into the goings on of LINQ to SQL. Not only does it allow you to see the SQL that is generated by your LINQ queries but it also shows you information about your connections, queries, as well as alerting you to all sorts of information that you might otherwise not know about.

    Read the article

  • Optimizing Memory Usage in a .NET Application with ANTS Memory Profiler

    Most people have encountered an OutOfMemory problem at some point or other, and these people know that tracking down the source of the problem is often a time-consuming and frustrating task. Florian Standhartinger gives us a walkthrough of how he used the ANTS Memory Profiler to help make an otherwise painful task that little bit less troublesome.

    Read the article

  • ANTS Profiler Saves Me From A Sordid Fate

    A bit of string concatenation never hurt anybody, right? Think again. Carl Niedner has been designing software since 1983, and was shocked to find his latest and greatest creation suddenly plagued with long loading times. After trying ANTS Profiler, he discovered one tiny line of forgotten concept code was causing his pain.

    Read the article

  • Stairway to Server-side Tracing - Level 10: Profiler versus Server-Side tracing

    Compares and contrasts tracing using Profiler with server-side tracing, illustrating important performance differences so that one can choose the right tool for the task at hand. Make working with SQL a breezeSQL Prompt 5.3 is the effortless way to write, edit, and explore SQL. It's packed with features such as code completion, script summaries, and SQL reformatting, that make working with SQL a breeze. Try it now.

    Read the article

  • Redgate ANTS Performance Profiler

    - by Jon Canning
    Seemingly forever I've been working on a business idea, it's a REST API delivering content to mobiles, and I've never really had much idea about its performance. Yes, I have a suite of unit tests and integration tests, but these only tell me that it works, not how well it works. I was also about to embark on a major refactor, swapping the database from MongoDB to RavenDB, and was curious to see if that impacted performance at all, so I needed a profiler that supported IIS Express that I can run my integration tests against, and Google gave me:   http://www.red-gate.com/supportcenter/content/ANTS_Performance_Profiler/help/7.4/app_iise   Excellent. Following the above guide an instance of IIS Express and is launched, as is Internet Explorer. The latter eventually becomes annoying, I would like to decide whether I want a browser opened, but thankfully the guide is wrong in that it can be closed and profiling will continue. So I ran my tests, stopped profiling, and was presented with a call tree listing the endpoints called and allowing me to drill down to the source code beneath.     Although useful and fascinating this wasn't what I was expecting to see, I was after the method timings from the entire test suite. Switching Show to Methods Grid presented me with a list of my methods, with the slowest lit up in red at the top. Marvellous.     I did find that if you switch to Methods Grid before Call tree has loaded, you do not get the red warnings.   StructureMap was very busy, and next on the list was a request filter that I didn't expect to be so overworked. Highlighting it, the source code was presented to me in the bottom window with timings and a nice red indicator to show me where to look. Oh horror, that reflection hack I put in months ago, I'd forgotten all about it. It was calling Validate<T>() which in turn was resolving a validator from StructureMap. Note to self, use //TODO: when leaving smelly code lying around.     Before refactoring, remember to Save Profile Results from the File menu. Annoyingly you are not prompted to save your results when exiting, and using Save Project will only leave you thankful that you have version control and can go back in time to run your tests again.   Having implemented StructureMap’s ForGenericType, I ran my tests again and:     Win, thankyou ANTS (What does ANTS stand for BTW?)   There's definitely room in my toolbox for a profiler; what started out as idle curiosity actually solved a potential problem. When presented with a new codebase I can see enormous benefit from getting an overview of the pipeline from the call tree before drilling into the code, and as a sanity check before release it gives a little more reassurance that you've done your best, and shows you exactly where to look if you haven’t.   Next I’m going to profile a load test.

    Read the article

  • Fun with SQL Server Profiler trace files and PowerShell

    Running Profiler traces against multiple servers becomes a painful process when it’s time to collate and filter all that data. It would be time-consuming, frustrating and messy if Laerte hadn’t written this handy PowerShell script (complete with examples) to help you out. Free trial of SQL Backup™“SQL Backup was able to cut down my backup time significantly AND achieved a 90% compression at the same time!” Joe Cheng. Download a free trial now.

    Read the article

  • Working with SQL Server Profiler Trace Files

    In a previous tip we looked at the steps to Create a Trace Template in Profiler. In this tip we will look at a few more tips such as creating a trace template from an existing trace file and saving a trace file to a SQL Server table. Free trial of SQL Backup™“SQL Backup was able to cut down my backup time significantly AND achieved a 90% compression at the same time!” Joe Cheng. Download a free trial now.

    Read the article

  • Determining Object Access Using SQL Server Profiler

    Deanna Dicken examines an SQL Server Profiler event to determine object access...who is using the object, when, and how. This gives the SQL developer or database administrator much needed information for impact analysis prior to a change or the decommissioning of a SQL Server object.

    Read the article

  • Django aggregation query on related one-to-many objects

    - by parxier
    Here is my simplified model: class Item(models.Model): pass class TrackingPoint(models.Model): item = models.ForeignKey(Item) created = models.DateField() data = models.IntegerField() In many parts of my application I need to retrieve a set of Item's and annotate each item with data field from latest TrackingPoint from each item ordered by created field. For example, instance i1 of class Item has 3 TrackingPoint's: tp1 = TrackingPoint(item=i1, created=date(2010,5,15), data=23) tp2 = TrackingPoint(item=i1, created=date(2010,5,14), data=21) tp3 = TrackingPoint(item=i1, created=date(2010,5,12), data=120) I need a query to retrieve i1 instance annotated with tp1.data field value as tp1 is the latest tracking point ordered by created field. That query should also return Item's that don't have any TrackingPoint's at all. If possible I prefer not to use QuerySet's extra method to do this. That's what I tried so far... and failed :( Item.objects.annotate(max_created=Max('trackingpoint__created'), data=Avg('trackingpoint__data')).filter(trackingpoint__created=F('max_created')) Any ideas?

    Read the article

  • Should we have a database independent SQL like query language in Django?

    - by Yugal Jindle
    Note : I know we have Django ORM already that keeps things database independent and converts to the database specific SQL queries. Once things starts getting complicated it is preferred to write raw SQL queries for better efficiency. When you write raw sql queries your code gets trapped with the database you are using. I also understand its important to use the full power of your database that can-not be achieved with the django orm alone. My Question : Until I use any database specific feature, why should one be trapped with the database. For instance : We have a query with multiple joins and we decided to write a raw sql query. Now, that makes my website postgres specific. Even when I have not used any postgres specific feature. I feel there should be some fake sql language which can translate to any database's sql query. Even Django's ORM can be built over it. So, that if you go out of ORM but not database specific - you can still remain database independent. I asked the same question to Jacob Kaplan Moss (In person) : He advised me to stay with the database that I like and endure its whole power, to which I agree. But my point was not that we should be database independent. My point is we should be database independent until we use a database specific feature. Please explain, why should be there a fake sql layer over the actual sql ?

    Read the article

  • Fix for EF4 Profiler Issue Coming in next Cumulative Update

    - by Ajarn Mark Caldwell
    Hey!  What do you know?  Microsoft Connect really works! I was very happy this morning to open my email and find a notice from Umachandar on the SQL Programmability Team that they have created a fix for the Odd Profiler Results with EF4 issue that I wrote about last June.  Not only did I blog about it, but I logged an item to Connect with repro steps and sample code.  And now, they have announced that they have a fix for this problem and that it will be included in the next Cumulative Update for SQL Server 2008 R2. For those of you not running 2008 R2, or who prefer to wait for full Service Packs rather than install the latest Cumulative Updates, I also wrote about a workaround for the issue, as long as you do not require the Multiple Active Result Sets feature to be enabled. It is easy with Microsoft to get the feeling that you’re just shouting in the wind, and it is nice to get validation once in a while that they really are listening.

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >