Getting data using doctrine in symfony by leftjoin

For leftjoin you must remember the relationship between classes in doctrine in schema file.

I have used schema.yml file for my database and its relationship with tables, for example I am give only two tables definition
sfGuardGroup:
actAs: [Timestampable]
columns:
name:
type: string(255)
unique: true
description: string(1000)
relations:
Users:
class: sfGuardUser
refClass: sfGuardUserGroup
local: group_id
foreign: user_id
foreignAlias: Groups
Permissions:
class: sfGuardPermission
local: group_id
foreign: permission_id
refClass: sfGuardGroupPermission
foreignAlias: Groups

sfGuardUserGroup:
options:
symfony:
form: false
filter: false
actAs: [Timestampable]
columns:
user_id:
type: integer
primary: true
group_id:
type: integer
primary: true
relations:
User:
class: sfGuardUser
local: user_id
onDelete: CASCADE
Group:
class: sfGuardGroup
local: group_id
onDelete: CASCADE

Table look lie this ( I have added some data)

sf_guard_group

id   name   description
1     admin       –
2    vendor     –
3     user         –

sf_guard_user_group

user_id    group_id
1                      1
2                     3
3                     3
4                     3
5                     2
6                     2
7                     3

Now you want fetch group name by sf_guard_group table. If you look at relationship you will find that there is a relationship name Users

I have written a function in sfGuardGroupTable.class.php [ you will get it while you build the tables ]
public function getGroupName(){
$q = Doctrine_Query::create()
->select('sgg.name')
->from('sfGuardGroup sgg')
->leftJoin('sgg.Users gs');

$q->setHydrationMode(Doctrine_Core::HYDRATE_SCALAR);

 

echo $q->getSQLQuery();
return $q->execute();
}

you will get the answers like this if you call in respective scope

$groupid = Doctrine_Core::getTable(‘sfGuardGroup’)->getGroupName();

echo “<pre>”;

$groupid = Doctrine_Core::getTable(‘sfGuardGroup’)->getGroupName();

print_r($groupid);

 

Array
(
[0] => Array
(
[sgg_name] => admin
)

[1] => Array
(
[sgg_name] => client
)

[2] => Array
(
[sgg_name] => client
)

[3] => Array
(
[sgg_name] => client
)

[4] => Array
(
[sgg_name] => client
)

[5] => Array
(
[sgg_name] => vendor
)

[6] => Array
(
[sgg_name] => vendor
)

)

Some useful url:

http://www.doctrine-project.org/documentation/manual/1_2/en/dql-doctrine-query-language#join-syntax:on-keyword

Starting with symfony framework in windows platform especialy with httpd

It is always exciting to learn new things. I have started to learn the  symfony framework. It was bit tough for me to setup the framework. But after a lot of pain I have successfully loaded it into my web server root. I want to share some of my problems and way to solve those problems.

You will find lots of books in the website for learning the framework. Though someone told me that it would be hard for me to learn this framework. Don’t really know about the learning curve of this framework.

learning book site : http://www.symfony-project.org/doc/1_4/

I am following the book:  http://www.symfony-project.org/jobeet/1_4/Doctrine/en/

Now few things,

1. You must set your php directory in your windows environment variable.

2. If your web root directory doesn’t support do it in your php.exe folder like: d:/xampp/php

3. While setting it up from command prompt remember you directory, the book might have some other directory

4. Its better to run the command from php.exe file containing folder

5. For getting help or know better from symfony installed components

d:\xampp\php> php lib\vendor\symfony\data\bin\symfony

6. I have changed my httpd.cof like this

# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080
<VirtualHost 127.0.0.1:8080>
DocumentRoot "D:\xampp\php\sfprojects\jobeet\web"

DirectoryIndex index.php
<Directory "D:/xampp/php/sfprojects/jobeet/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf "D:\xampp\php\sfprojects\jobeet\lib\vendor\symfony\data\web\sf"
<Directory "D:/xampp/php/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">

AllowOverride All
Allow from All
</Directory>
</VirtualHost>

7. Dont forget to restart your Mysql after changing httpd

Trace Route & Trace Route Locator

For trace route you just need to do the following steps

1. go to start menu and click on run

2. type cmd and press enter

3. type tracert ‘site name’ and press enter, for example –> tracert zeasite.com

You will find the hops and ip addresses of your site routes. Now if you want to locate them there is a very useful site whose link is http://www.geobytes.com/TraceRouteLocator.htm. Just copy your trace route from your command prompt window and paste to the above page, it will show the location. Now you might have the problem to copy the text from the command prompt window. Follow the procedure to copy from the command prompt window.

1. Right click on the menu bar of command prompt window (blue bar)

2. There you will find a option named edit, where you will find a sub menu option named mark, click on that.

3. Now drag the portion you want to copy with mouse and then again right click on the command prompt menu bar and go to edit option and select copy (you can drag for one time only, so if you miss it you need to do the copy process again). Now you can paste it anywhere you want to.

10 things you should do to a new PC before connecting it to the Internet

Takeaway: A Microsoft Windows PC that has not been updated for security vulnerabilities will be compromised by some from of malware within minutes of connecting to the Internet. Take steps to protect yourself before you start Web surfing.

Click the following link for details:

http://i.techrepublic.com.com/downloads/home/10_things_new_pc.pdf

The 10 biggest mistakes IT managers make


1: Focusing on technology and not the business

The typical IT manager comes from a technical background in either infrastructure or development. Based on their technical roots, they tend to focus their efforts in their expertise when in fact they should be looking for ways to support, enable, and improve the business. To be successful, IT managers must become business leaders and turn their focus and expertise to business issues and problems first.

2: Thinking “out of sight is out of mind”
It’s important to remember that in IT, no news is not good news. IT managers tend to trudge along without ever looking at their progress. The most powerful task you could ever do is an assessment. There are several ways to do this. You can do a SWOT (Strengths, Weaknesses, Opportunities, and Threats) analysis or you can do a full-blown formal IT assessment. You might even use a scorecard system to track where you are as a department. You can download a free scorecard developed specifically for this purpose.

3: Thinking that your team has it covered
In the TV show The Apprentice, so many teams ended up in the boardroom because the leader delegated a job but didn’t follow up to make sure it was done right. Following up is not micromanagement. It’s your job as a leader to ensure that the task gets done correctly.

4: Not inspecting what you expect
This mistake has its roots in mistake number 3 but can be carried forward into other aspects of IT. For instance, you could possibly expect great performance out of your servers but may not have a system to make sure they’re running at peak capacity. This ultimately leads to poor planning, budgeting, staffing, etc. If you want to avoid this common pitfall, make a comprehensive list of expectations for your entire department. This could include critical projects, network and server performance, client satisfaction, etc. Double-check the list to make sure you are inspecting all expectations on a regular basis. Keep a checklist or develop a daily disciplines worksheet to follow everything that needs daily inspection.

5: Not creating a partnership with business management
I find a great deal of IT managers reporting to operations and finance personnel instead of presidents and CEOs. The only way IT can be an effective and strategic element to business is through partnership with business executives. You must lead and influence your reports, peers, and leaders to have a maximum impact on the organization. The quicker you can get on the leadership team, the quicker you will have the ability to execute on number 1.

6: Burning yourself out
I can’t tell you how many IT managers I coach who have not had vacations in a year or longer and routinely work more than 70 hours per week. This is not only a mistake, but it’s a formula for disaster. Sometimes the thinking is that your business can’t live without you. The truth is, your business cannot live with you burning yourself out. It only leads to lowered productivity and, eventually, your giving up or getting disgruntled. Do yourself, your business, your employees, and your family a favor and take some time off.

7: Not testing your backup solution
I always tell my new IT managers that one of the most important aspects of their jobs is ensuring a reliable backup. Breakdowns in technology hardware are inevitable. The next best thing is fault tolerance, but I have even seen that fail. Don’t think for a minute that if you have tapes and if everything looks okay in your system that everything is okay. Make sure you test backups regularly. Do test disasters and make sure you can recover.

8: Not asking for help
Too often, I’ve seen costly mistakes made by managers and technicians who try to solve an issue alone without informing anyone or even reading the manual. This is a costly mistake. If you get in over your head, do the right thing and seek help. The key to successful IT management is not knowing the right answers; it’s being able to find them and execute a solution as quickly and cost effectively as possible. Don’t hesitate to bring in the experts where necessary.

9: Not devoting time to personal development
There’s no excuse for this mistake. Personal development is not your company’s responsibility — it’s yours. I can always tell a person’s success potential by the last five books they’ve read and by the seminars they attend. Every IT manager should be devoting at least 30 minutes a day to personal development. The truly successful devote even more — in some cases, upwards of two hours or more per day. The most common excuse I hear is the lack of time or money. The answer lies in the successful management of money and time.

10: Not finding a mentor or coach
The quickest route to success is to find someone who has been there and then emulate that person. The quickest road to pain, hardship, and failure is to go the journey alone. Whether you’re in management or not, you should always have a mentor or coach and you should always be mentoring or coaching someone else. A coach will help you achieve more than you could by yourself by imparting wisdom, accountability, and crucial advice where necessary. By coaching or mentoring someone else, you’re doing the same, but you’re also solidifying your own concepts by teaching them to others.

source: http://blogs.techrepublic.com.com

ctrl ( control ) D in debian ( linux )

Sometimes we face the problem of control D in debian. In this scenario you must unmount all the drives of your hard disk then you need to go through file scan for recovery and fixation.

1. Give the root password
2. fdisk – l
It will show all the partitions of your hard disk
controld ctrl ( control ) D in debian ( linux )
this is my hard disk, you might have lot more or less

3. Now you need to unmount all of the partition, command is as below
umount /dev/sda1
..
..
umount /dev/sda5

4. Now run file scan, command is
fsck

you might have to press y for several times for fixing the errors. After completing the fsck restart the machine

5. init 6

CS4, CS5 : Use action and batch command / process ( batch processing ) in photoshop for multiple images to resize

Some times its easier to use batch file with action to reduce the image size or create auto levels or use auto filters for multiple images. To create the action and batch file you need to do the following tasks.

1. Open Adobe photoshop
2. Then open an image.
3. Go to window menu and select action. A window will pop up
4. In that action pallet you can find ‘new set’ button, click on that and create a new set named “zea set”.
5. Then in the action pallet you will also find a button named ‘new action’ button click on that create an action named “zea action” and press record. your recording will start now.
6. now whatever you do, it will be recorded, for instance if you make auto levels, it will remember that you made auto levels command.
7. Do what ever you want to do and save the file and close it.
8. Now press on ‘stop playing/recording’ button in the action pallet.
9. Click on file menu you will find a sub menu named automate click on that there you can find another sub menu batch… (file -> automate -> batch…) click on that and there will be a window named ‘Batch’.
10. Now select ‘zea set’ and ‘zea action’ from the set and action field on ‘Batch’ window.
11. chose the path containing the images that you want to do the same thing(that you have done for the earlier image) for all the images. you can also chose a destination path. then click ok.