Query mysql database in extjs - php

We are developing an extjs app that retrieves data from database via php and mysql. We see that it is possible, however we are curious about other possibility of accessing mysql database with extjs.
In fact, we are not sure whether this old-school way is the way to do it efficiently in extjs.
So are there other methods available for extjs?

It is possible to use ExtJS server side. You'd probably need to utilize Node.js...there are MySQL drivers for Node by the way.
Here is a project that uses ExtJS models on the back end with Node. This might help you get an idea of what is possible.
https://github.com/storminwalker/node-extjs

Related

Using the EXTJS 4 writer.js example - need to create PHP back-end code for CRUD to Oracle DB

I am looking into using the EXTJS 4 writer.js example concept to create an application, but I need to be able to perform all my CRUD operations to a real Oracle database instead of to a SESSION. I am using PHP to perform the CRUD operations instead of to a SESSION variable. Does anyone know what I need to do to write, or can anyone point me in the direction of someone who has done this already, to create the proper back-end code for using PHP to write to a Oracle database using this writer.js example?

suggestions on how to approach creating a mysql webservice/api

Sorry in advance if my wording is wrong because I'm not quite sure how to explain what I want, so I'll just describe the end result.
I have a php based excel tool called socialcalc(it was wikicalc before). I want to allow users to connect to a database and pull live data onto the sheets(so they can run calculations on it).
I understand that for sure socialcalc will have to query mysql but I'm trying to figure out the most effective way. Is it better to allow it to query it directly? or should I have it query the database an get an xml file as a result? Or what other ways would you suggest is a efficient and secure way of allowing read access to the data?
We're building alot of the this ontop socialcalc from scratch so pretty open to all solutions but ultimately, we want this to power other services.
Update: to clarify, I am looking for suggestions on using SOAP/XML over say directly querying the database or using HTTP POST/GET,etc..which type of service layer would you suggest or what are the factors to consider when choosing?
"Simple is better than complex."
You could certainly implement a Web Service layer between your application and MySQL, but ask yourself why you would want this. You might want it because:
You plan on changing backend systems at some point in the future and don't want to have to refactor business logic in the front-end application
You want to expose your backend data to other applications and provide a common interface for doing so
You want to implement smoe sort of caching/persistence strategy in the middle tier
All of those would be valid, good reasons to use a Web Service layer between your application and your database. Certainly there are more valid, good reasons as well.
If you can't think of a reason why you should implement a Web Services layer, then don't, it's that simple. You can always decide to later when there is a good reason.
EDIT:
So you've decided to go ahead with the Web Service...congrats! I think in that case you should look at two key frameworks to save you a lot of time:
Get a good ORM framework that can generate the vast majority of your CRUD logic. Doctrine is a popular choice for PHP.
Use a Web Services framework for implementing your interfaces and business logic. I've done this in the past using the Zend Framework, as they support both XML and JSON payloads via REST. XML and SOAP are great if you need strict data validation requirements, but if you're the only one consuming your own Web Service, you don't need to impose such limiations on yourself, as you know your requirements. In that case, JSON should be sufficient.
By the way, I've discussed RESTful services via Zend in another previous question:
lightweight RESTful PHP server
I think the best approach is by using a step-to-step action.
Sep one
Let the user choose the data he want to implement in his excel sheet. How to do this is up to you.
Step two
Submit the choise of the user to a own created SQL API. This API will check the input for injections and so on and will do all the query en retrieval of data.
Step three
Send teh retrieved data to a class which will create the excel file.
Step four
Send the created excel file to the user.
The most importent part of this is the SQL api. This is a class which handles all the input from the user and communication with the database. It can use normal SQL statements but you cna use it to validate all the data.
Hopefully this is some use for you.

Using stored procedures in Symfony - pros and cons

I'm writing a web application in Symfony for the first time, so I have a question regarding the use of Doctrine vs. Stored Procedures.
My background is in Java server-side, so I wanted to know what the pros and cons are for using stored procedures, versus using simple Doctrine code to get things done. At the most basic level, let's say that my Symfony web application is used for management, while there's another engine (which might or might not be written as a Symfony component, or indeed not in PHP at all) which retrieves configurations from the database for distribution or whatnot. Here I can see where stored procedures might be handy: both code bases use them to query and access data, while neither are preoccupied with the actual schema. If there's a change to the schema (adding a column in some table, for instance), then I'd only have to change the SRPOC, and nothing else, whereas if I had been using code in both engines to access data, I'd have to change them both to match the new schema.
Any comments? Or did I take it too far?
Thanks!
-DBG
If you don't use doctrine, you loose database abstraction, and object mapping. And this is a major loss. If you need third party apps integrations, you shouldn't let them interact with your database. Rather, provide a web service for them to read/write data via JSON, for example. This way you can change your database schema and have control over third-party apps.

Database design for tagging

I want to implement a tagging system for entries in my database. I did some research and I guess that this is the best way to do it...however I'm not too experienced with MySQL (or PHP for that matter - I'm just making a sort of web app for fun) and thus I am confused on how to implement this.
Your going to need to create the database in MySQL and then you will need to use PHP to create the user interface (HTML) and the code to access the database. Since you are new I've listed out some getting started resources for each. Good Luck!
Here's some resources for getting started with MySQL:
http://code.google.com/edu/tools101/mysql.html
http://a.parsons.edu/~kosoyj/2009/spring/pgte_5044/2009/03/24/mysql-101/
http://www.killerphp.com/mysql/
http://www.webdevelopersnotes.com/tutorials/sql/mysql_database_introduction_mysql_beginners_tutorial.php3
And some for basics/getting started with PHP:
http://devzone.zend.com/article/627
http://www.homeandlearn.co.uk/php/php.html
http://www.webmonkey.com/2010/02/php_tutorial_for_beginners/
Learning PHP and MySQL
The link you provided is ideal. You should just start in on learning how to make a many-to-many relationship as the link explains. But what are you using to edit PHP or try out queries?

Does a MySQL, PHP, JSON framework exist?

I'd like to query a MySQL database via a RESTful service with the middleware being PHP. I'd like the output to be JSON. I'm a beginner in those areas. Are there any frameworks or scripts that can do this without requiring you to be an expert? I don't have a problem stringing a few scripts together if they can work.
Or, if it can be done much simpler without using REST (i.e. query parameters), that's fine.
In the end, I want to have an iPhone app fetch this data and have it returned via JSON. No javascript will be involved.
You can convert a MySQL result set to JSON easily: http://phpclasses.nlared.com/browse/package/3195.html
For a RESTful interface, basically any hosted PHP script can function as a REST interface for your application.
Check out this project: http://phprestsql.sourceforge.net/
On this site you will find a RESTful
interface (written in PHP) to a
database (a MySQL database, but that's
not important). Below you will find a
interactive tutorial that will get you
accessing, adding and deleting rows
from our database via our Javascript
powered REST browser.
The PHP shouldn't necessarily be your middleware in your situation, you'll have to build your "RESTful" service somehow, whether it be with PHP or any other language. You don't have to be an expert, but I think CakePHP has some of these capabilities.
Maybe explain in more detail what you want to do.
Update
Try this out:
http://techno-geeks.org/2009/08/easy-json-with-cakephp-and-jquery/
Not only is CakePHP easy to install and use, it's also easy to extend.

Categories