CakePHP: How To Use ‘neighbors’ With ‘find’ Method

CakePHP ‘find’ method makes it easier to retrieve data from database. The ‘find’ method can be used to construct anything from extremely simple queries to more complex ones without writing much code. This method can handle most SQL type requests and can be extended for more specific SQL queries.  I will walk you through the below example about the basics of working with the ‘find’  method

Here Are Some Inbuilt Types in CakePHP

  1. $this->Model->find(‘all’,$condition);
  2. $this->Model->find(‘first’,$condition);
  3. $this->Model->find(‘count’,$condition);
  4. $this->Model->find(‘list’,$condition);
  5. $this->Model->find(‘neighbors’,$condition);
  6. $this->Model->find(‘threaded’,$condition);

First four types are the most commonly used in CakePHP
Now, let’s take a look at an example of ‘neighbors’ type

Example

Let’s assume QuizQuestion is your model and you want to fetch the previous and next entries

Your Controller/action will look like,

public function getNeighbors($id){
 
$this->QuizQuestion->id = $id;
 
$neighbors = $this->QuizQuestion->find('neighbors',array('fields'=>array('id','question_no','description')));
}

A couple of queries will be generated in SQL as,

Query: SELECT 'QuizQuestion'.'id', 'QuizQuestion'.'question_no', 'QuizQuestion'.'description',
'QuizQuestion'.'id' FROM 'quiz_questions' WHERE 'QuizQuestion'.'id' < 38   ORDER BY
'QuizQuestion'.'id' DESC  LIMIT 1
Query: SELECT 'QuizQuestion'.'id', 'QuizQuestion'.'question_no', 'QuizQuestion'.'description',
'QuizQuestion'.'id' FROM 'quiz_questions' WHERE 'QuizQuestion'.'id' > 38   ORDER BY
'QuizQuestion'.'id' ASC  LIMIT 1

Here’s the output

Array
(
[prev] => Array
(
[QuizQuestion] => Array
(
[id] => 37
[question_no] => 1
[description] => Mathematics
)
 
)
[next] => Array
(
[QuizQuestion] => Array
(
[id] => 39
[question_no] => 3
[description] => Mathematics
)
 
)
 
)

Voila! Using the result keys ‘prev’ and ‘next’ you can view the results the way you want.

Sweet Journey | New IOS App From Andolasoft

We are excited to announce that ‘Sweet Journey’ – a diary app is now in App Store. Deployed last week, got overwhelming responses with over 100 downloads around the world. It is a personal diary on the go. You could use it as a journal or photo album to keep your memories safe. Capture photos, videos and take notes, all in one app.

Download ‘Sweet Journey’ from App-Store

sweetjourney_logo

Journals and diaries are great to use, but it is vulnerable to threats like damage, lost. So, we came-up with an unique app idea to make note taking easier. If you like to carry around a journal and scribble notes, why not capture that on your iPhone or iPad. It would be easier, faster and insightful. You could do more than just writing notes and taking photos.

What You Can Do With Sweet Journey

  • Create notes with date and time
  • Capture snaps and videos with tags and timestamp
  • Record voices with tags and timestamp
  • Save photos with Geo-tag to see in map view, based on location
  • Store memories in one gallery and sort as per day, month and year

Here’s What We Did:

  • Designed the application logo, user interfaces (UI/UX) and animation effects
  • Developed the app in native language i.e. Objective-C and Cocoa Touch framework
  • Devised the application process and flow from navigation to monetization
  • Implemented Tapku SDK
  • Used iCarousel library for paged and scroll view
  • Deployed the app to App Store within 3 weeks since the initiation of project

So, go ahead; download the app and see how ‘SweetJourney’ can help memories last forever. Feel free to write reviews in iTunes.

Auditnet_appstore1

 

 

SJ_sc_small

 

How To Create A Gridview With ‘UICollectionView’ In IOS6 & Above

What Is ‘UICollectionView’?

‘UICollectionView’ is a class introduced in iOS 6 SDK. It helps developers in creating grid view to handle ordered collection of data items using customizable layouts. ‘Collection view’, available in this class is like ‘UItableview’ which supports multiple column layouts.

Getting Started:

Create new ‘.h‘ and ‘.m‘ files to display the images.

In ‘ShowImagesViewController.h

#import <UIKit/UIKit.h>
@interface ShowImagesViewController :UICollectionViewController
{
NSArray *allImages;
}
@property (nonatomic, retain) NSArray *allImages;
@end

In ‘ShowImagesViewController.m

#import "ShowImagesViewController.h"
@implementation ShowImagesViewController
@synthesize allImages;
- (void)viewDidLoad
{
[superviewDidLoad];
allImages = [NSArrayarrayWithObjects:@"pizza.jpeg",
@"sides_img.png", @"sandwich_img.png", @"pizza_img.png",
@"pasta_img.png", @"drinks_img.png", @"pizza.jpeg",
@"sides_img.png", @"sandwich_img.png", @"pizza_img.png",
@"pasta_img.png", @"drinks_img.png", nil];
}
 
- (void)didReceiveMemoryWarning
{
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (NSInteger)collectionView:(UICollectionView *)collectionViewnumberOfItemsInSection:(NSInteger)section
{
returnrecipeImages.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionViewcellForItemAtIndexPath:(NSIndexPath *)indexPath
{
staticNSString *identifier = @"Cell";
UICollectionViewCell *cell = [collectionView
dequeueReusableCellWithReuseIdentifier:identifier
forIndexPath:indexPath];
 
UIImageView *allImageView = (UIImageView *)[cell viewWithTag:100];
allImageView.image = [UIImageimageNamed:[allImagesobjectAtIndex:indexPath.row]];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionViewdidSelectItemAtIndexPath:(NSIndexPath *)indexPath{
}
@end

Example of Grid layout using ‘UICollectionViewController

uicollectionview

Conclusion:

‘UICollectionViewController’ creates ‘Grid’/’Tile’ layout much faster and offers intuitive user interface in iOS 6 devices.

How We Turned A Great Idea Into IOS App – The Inside Story

Sandra M, an Occupational Therapist (OT) in the USA, came-up with the original idea and approached us to put it into iPhone app development as well as iPad app development. Here, the therapists share their expertise through the app thereby mentoring new parents through shared interventions.

The ‘LittleSteps’ iOS app is now in App Store. In a short span of time, hundreds of downloads have been done across the USA, Germany, Australia, India, Philippines, UK, China, Ireland, Portugal, Greece, Israel, South Africa, New Zealand, Chile, Egypt, Germany and Canada.

icon_lS

The ‘LittleSteps’ App is aimed to collaborate and share OT interventions to address developmental delay in the areas of fine motor, gross motor, feeding, sensory integration, visual motor, behavior, language development and social skills for children below 3 yrs. With the free version a user can share interventions applied to other users. However, the paid version allows OT to store customer data in the device itself.

For Occupation Therapists, it provides a platform to share knowledge and take care of certain condition during baby’s growth. For parents, it acts as a companion that makes them knowledgeable on baby care.

Being one of the best iPhone App Development Companies, we came-up with the right solutions that turned Sandra’s idea into a working iOS app. We included numerous functionalities and integrations that made it engaging and simple for the users. We used Orangescrum, the project collaboration tool to keep-up with the development process.

See What Users Are Saying About The App?

  • “Very informative! Great app to download!”
  • “OMG, this is an exceptionally amazing app that has transformed the way we approach raising our babies. A must for all parents”

Here’s What We Did:

  • Designed the application logo, the user interfaces (UI/UX)
  • Developed the app in native language i.e. Objective-C and Cocoa Touch framework
  • Devised the application process and flow from navigation to monetization
  • Introduced the feature of In-app purchase for premium users
  • Introduced push notification feature to share texts instantly
  • Tested the app’s performance with AppFlight SDK
  • Deployed the app to Apple App Store within 9 weeks since the initiation of project

In addition to above mentioned functionalities, we have introduced numerous other features that make it a state-of-the-art application.

So, go ahead; download the app and see how ‘LittleSteps’ can help you and your baby. Feel free to write reviews in iTunes.

ios_mobile

 

 

LS_screenshot

Auditnet® Is Now Available On Mobile (iPhone/iPad/Android)

We are delighted to announce that AuditNet® is now available on Mobile both iPhone/iPad and Android. With this app, now the existing users can enjoy browsing and downloading the same rich content what they see on web app, also a new user will be able to register to the site. Now advertisers will get traffic from both web and mobile application.  For last 12 weeks a dedicated team from Andolasoft (Mobile App Developers, UI Developers, Ruby On Rails developers and QA team) worked diligently to make it available on the app stores right on time. AndolaSoft team worked on UX/UI design, app development, testing, and deployment of app to the respective apps store.

Looking into current surge of iPhone, iPad and Android devices worldwide, AuditNet® started looking for a way to provide access to the audit templates to its mobile users to target rise in subscriptions. Hence, Andolasoft proposed a cost effective solution by developing a mobile app using Cross Platform technology – PhoneGap, on top of Ruby on Rails framework, enabling to run on both iOS and Android platform. The back-end uses RESTful API hosted on AWS for smoother performance.

 

Auditnet_mobile_image

Auditnet_appstore1Auditnet_googleplay

 

 

About Auditnet:

AuditNet® serves the global audit community as the primary communication resource with an online digital network where auditors share resources, tools, and experience including audit work programs and other audit documentation. In 2009 AuditNet® launched Web-based training for fraud detection and prevention, IT audit, data analysis, audit software tools and techniques, enabling auditors to learn essential skills anywhere at any time. As a NASBA approved CPE sponsor AuditNet® now offers low-cost high-quality training for auditors and financial professionals, providing convenience while eliminating the need for travel.

Visit www.auditnet.org to know more.

About AndolaSoft:

Based in Silicon Valley, Andolasoft is a Web and Mobile app Development Company. Here, we do web applications using Ruby on Rails, PHP and CakePHP. We’ve expertize on Mobile App Development involving as iPhone, iPad, Android, PhoneGap andSencha.
With a team of 200+ expert developers, we deliver cutting-edge solutions within budget and on schedule. We have happy customers from across the USA, UK, Australia, Canada, Singapore, Switzerland and Brazil.

Visit andolasoft.com to know more

Supercharge your Rails app development with “Metric_fu”

Why we need Metric_fu?

Sometimes we are unaware of unknown complexities in our rails code and it gets messy. Moreover, it reduces application performance, scalability and maintainability.

What is Metric_fu?

Metric_fu is a set of rake tasks and compilation of several different tools that provides reports. This show which parts of your rails code might need extra work. It uses the following built-in tasks to create a series of reports.

  • Rcov – Measures test coverage
  • Flog – Measures code complexity
  • Saikuro – Measures cyclomatic complexity
  • Flay – Finds duplication (both copy/paste and structural)
  • Reek – Spots code smells
  • Roodi – Finds lots of general problems
  • Churn – Identifies files that changes too often
  • Rails best practices – code matric tool
  • Cane -code quality threshold violations
  • HotSpot– Meta analysis of your metrics to find hotspots in the code

Benefits of Metric_fu

  • You can measure the complexity of rails code
  • Creates a “hit list” of most complex methods
  • Reveals hidden issues like bugs and other complexities
  • Examine worst offenders
  • Refactoring complex methods
  • Creates smaller, easier to understand methods

Step#1

  • Add ‘metric_fu’ gem to your gem file
gem "metric_fu"
  • Run “bundle install”

Metric_fu will install several other dependencies unless they are already present.
These include Flay, Flog, Rcov, Reek, Facets and Roodi.

  • Run following command to generate the metrics
rake metrics:all

It will generate a metric of your code in the temp/matric_fu repository,
it uses a number of other open source project to generate the metric.
metrics_home_page-1024x551

Rails_best_pratices_metrics-840x1024

Code analysis isn’t an exact science and none of the tools shown are perfect in themselves.
So they should all be used as an aid to help you find complex areas of your code and supercharge Rails app development.