Category Archives: Tools

What are ORM Frameworks?

ORM is a short form of Object Relational Mapping, means as ORM framework is written specifically in OOP (object-oriented programming) language (like PHP, C#, Java, etc…) and it is like a wrapper around a relational database (like MySQL, PostgreSQL, Oracle, etc…). So, ORM is basically mapping objects to relational tables.

What does an ORM framework do?

The ORM framework generates objects (as in OOP) that virtually map the tables in a database. So, any programmer could use these objects to interact with the database without writing an optimized SQL code.

For example:

We have 2 tables in a database:

  • Products
  • Orders

The ORM framework would create 2 objects corresponding to above tables (like products_object and orders_object) with little configuration, which will handle all the database interaction. So, if you want to add a new product in products table, you would have to use products_object and save() method like below,

You can see that, how much easier an ORM framework can make things. No need to write any SQL syntax. And application code would be very clean.

Some other advantages of using ORM frameworks

1. Syncing between OOP language and the relational database data types is always creating a problem. Sometimes variable data types have to be converted properly to insert into the database. A good ORM framework will take care of these conversions.

2. Using an ORM will create a consistent code base for your application since no SQL statements are written in the code. This makes it easier to write and debug any application, especially if more programmers are using same code base.

3. ORM frameworks will shield your application from SQL injection attacks since the framework will be filtering the data before any operation in the database.

4. Database Abstraction; Switching databases for the application is easier as, ORM will take care of writing all the SQL code, data type conversions etc …

When to use an ORM framework?

An ORM framework becomes more useful as the size and complexity of the project increases. An ORM framework may be overkilling an application on a simple database with 5 tables and 5-6 queries to be used for the application.

Consider the use of ORM when:

  • 3 or more programmers are working on an application.
  • Application database consists of 10+ tables.
  • The application is using 10+ queries.

About 80-90% of application queries can be handled by the ORM generated objects. It is inevitable that at some point straight SQL query is required, which can’t be handled by ORM generated objects.

In fact, ORM frameworks often have their own *QL query language that looks a lot like SQL. Doctrine, a popular PHP based ORM framework has DQL (Doctrine Query Language) and the very popular Hibernate (used in the Java and .Net world) has HQL. Going even further, Hibernate allows writing straight SQL if need be.

ORM Frameworks for PHP programmers

  • CakePHP, ORM, and framework for PHP 5
  • CodeIgniter, a framework that includes an ActiveRecord implementation
  • Doctrine, open source ORM for PHP 5.3.X
  • FuelPHP, ORM, and framework for PHP 5.3. Based on the ActiveRecord pattern.
  • Laravel, a framework that contains an ORM called “Eloquent” an ActiveRecord implementation.
  • Maghead, a database framework designed for PHP7 includes ORM, Sharding, DBAL, SQL Builder tools etc.
  • Propel, ORM and query-toolkit for PHP 5, inspired by Apache Torque
  • Qcodo, ORM, and framework for PHP 5
  • QCubed, A community-driven fork of Qcodo
  • Redbean, ORM layer for PHP 5, creates and maintains tables on the fly
  • Yii, ORM, and framework for PHP 5. Based on the ActiveRecord pattern.
  • Zend Framework, a framework that includes a table data gateway and row data gateway implementations. ZendDb

Using Tooltipster Plugin with jQuery Validation

Any many websites, during the form filling process, we show error messages in tooltips. Today we are trying to achieve the same for our websites.

Prerequisites:

  1. Tooltipster Plugin version 2.1 or 3.0 (The raw code for version 2.1 can be found inside the first jsFiddle below.)
  2. jQuery Validate Plugin

First, initialize the Tooltipster plugin (with any options) on all specific form elements that will display errors:

Second, use Tooltipster’s advanced options along with the success: and errorPlacement: callback functions built into the Validate plugin to automatically show and hide the tooltips as follows:

Note that this code example takes advantage of the new Tooltipster API features released in version 2.1 on 2/12/13

For Tooltipster version 3.0

The latest version of Tooltipster, version 3.0, is supposed to be working more correctly than version 2.1.

That’s fine, except that an animation flicker is now occurring on every single keystroke even when no content has changed. I suppose we could disable the default onkeyup option in jQuery Validate, but when multiple rules are used, the user would not be aware of his data entry violation until after leaving the field or clicking the submit button.

The workaround is to set the updateAnimation option to false.

The Tooltipster developer made the following suggestion to preserve the message update animation in version 3.0, which works very nicely. From within the jQuery Validate plugin’s errorPlacement callback function, this simple code makes sure the error message is not blank and has changed before calling Tooltipster’s show method. This has the added benefit of greatly reducing the number of calls to Tooltipster.

 

phpMyAdmin gives 404 error in localhost

To run phpmyadmin without getting 404 error, configure apache.conf for phpmyadmin.

Then add the following line to the end of the file.

And restart apache

Please read this section in Ubuntu wiki describes the 404 error problem for phpmyadmin.

Alternative of PHP_Excel for Excel Reading and Writing

For Writing Excel

For Reading Excel

For Reading and Writing Excel

  • Ilia Alshanetsky’s Excel extension now on github (xls and xlsx, and requires business libXL segment)
  • spout OfficeOpenXML (xlsx) and CSV
  • The Open Office different option for COM (PUNO) (requires Open Office introduced on the server with Java support empowered)
  • PHP’s COM extension (requires a COM empowered spreadsheet program, for example, MS Excel or OpenOffice Calc running on the server)
  • SimpleExcel Claims to read and compose MS Excel XML/CSV/TSV/HTML/JSON/and so forth arranges

Another C++ Excel expansion for PHP, however you’ll have to manufacture it yourself, and the docs are really meager with regards to attempting to discover what usefulness (I can’t discover from the site what groups it bolsters, or whether it peruses or composes or both…. I’m speculating both) it offers is phpexcellib from SIMITGROUP.

All case to be quicker than PHPExcel from codeplex or from github, however (except for COM, PUNO Ilia’s wrapper around libXl and spout) they don’t offer both perusing and composing, or both xls and xlsx; might never again be upheld; and (while I haven’t tried Ilia’s expansion) just COM and PUNO offers the same level of control over the made exercise manual.

Source: http://stackoverflow.com/questions/3930975/alternative-for-php-excel

Pencil Project – An open-source GUI prototyping tool

Pencil Project, a free, open-source, cross-platform GUI prototyping tool, that people can easily install and use to create mock-ups in popular desktop platforms. Pencil is available as a standalone application and a Firefox extension. You can download it from here.

Pencil provides various built-in shapes collections by default, which includes flowchart elements, desktop/web UI elements, Android/iOS GUI shapes and general purpose shapes for drawing different types of user interface ranging from desktop to mobile platforms. There are also many other freely distributed collections on the internet provided by the community, which can easily installable to Pencil with simple drag-and-drop operation.

Pencil has pre-installed stencils for Android and iOS UI, which makes it even easier and faster to start prototyping apps with a simple installation. These stencils are included from version 2.0.2. Some of the stencil collections that you can try are collected in the download archive.

Drawing diagrams are as easy as UI design in pencil, because of its collection of flowchart shapes. Pencil also supports connectors used for “wire” shapes in the diagram.

Pencil provides a clipart browser tool integrated with OpenClipart.org to let users easily find cliparts and add them into the drawing by simply drag-and-drop. These cliparts are in vector format, which are easily scalable to appropriate sizes.

Pencil can export drawings into most of the popular formats including OpenOffice/LibreOffice, Image formats (JPG, GIF, PNG), text documents, Inkscape SVG, Adobe PDF and HTML page that can deliver to viewers.

For the web UI, Pencil provides links of an element to specific page in the same document. These links are converted to hyperlinks when the document is exported into HTML pages. This helps the user to understand the UI flow of an application mockups.

For more information about the pencil project, click here.
Firefox extension can be downloaded from here.