Archive

Archive for the ‘database’ Category

Symfony 1.4 Doctrine Pagination

May 14th, 2010 R Arun Raj No comments

Doctrine Pagination is made very simple .

public function executeIndex(sfWebRequest $request)
  {
    $this->pager = new sfDoctrinePager('TableName', sfConfig::get('app_max_jobs_on_homepage');
    $this->pager->setQuery(Doctrine::getTable('TableName')->createQuery('a'));
    $this->pager->setPage($request->getParameter('page', 1));
    $this->pager->init();
 }

Success page

<?php foreach ($pager->getResults() as $post): ?><div>
<?php if($post->getTitle()) { echo link_to($post->getTitle(), ‘news/fullstory?expand=’.$post->getId(),’class=”mhead”‘); } ?>
<?php if($post->getDn2()!=”) { echo image_tag($post->getDn2()); } ?>
<?php $content=$post->getContent();
$stripcontent=substr($content,” “,700);
echo $stripcontent;
?>
<div style=”display:block;” > <?php echo $post->getCreatedAt(); ?><?php echo link_to(“Full Story”, ‘news/fullstory?expand=’.$post->getId(),’class=”fullstory”‘) ?> <br /><br />
</div></div>
<?php endforeach ?>

pagination

<?php if ($pager->haveToPaginate())  { ?>

<div id=”navv”>

<?php echo link_to(‘Latest’, ‘news/index?page=’.$pager->getFirstPage(),’class=”pager”‘) ?>
<?php echo link_to(‘prev’, ‘news/index?page=’.$pager->getPreviousPage(),’class=”pager”‘ ) ?>
<?php $links = $pager->getLinks(); foreach ($links as $page): ?>
<?php echo ($page == $pager->getPage()) ? $page : link_to($page, ‘news/index?page=’.$page,’class=”pager”‘) ;?>
<?php if ($page != $pager->getCurrentMaxLink()): ?> <?php endif ?>
<?php endforeach ?>
<?php echo link_to(‘next’, ‘news/index?page=’.$pager->getNextPage(),’class=”pager”‘) ?>
<?php echo link_to(‘Oldest’, ‘news/index?page=’.$pager->getLastPage(),’class=”pager”‘) ?>
<?php } ?></div>

PHP 6 upgrade : Advantages covered

September 14th, 2009 R Arun Raj No comments

PHP Personal Home Page now it is Hypertext Pre Processor.

Version : 6 (PHP 6)

Advantages,

  • Addition of improved MySql Extension
  • PHP 6 support Unicode, so that PHP 6 can handle all languages in the world. I faced lot of problems with ‘Malayalam’ font integration.
  • PHP 6 cleans up a lot of garbbages that was left in php 5
  • The two biggest removals are the “Magic Quotes” and “register globals” features

Download and Test PHP 6 at http://snaps.php.net/

What is magic Quotes ?

It automatically escapes single quotes or double quotes in form data by inserting a “\” Back slash in front of it. Now this automatic feature called magic Quotes has been removed  in PHP6.

Categories: Mysql, PHP, Programming Tags:

My Cv page updated

April 17th, 2009 R Arun Raj No comments
Categories: Mysql, PHP, asterisk Tags:

How to create a directory structure ?

March 7th, 2008 R Arun Raj No comments

How to create a directory structure ? or
How to creata a tree structure  ? or
How to design a database for a tree structure ? or
How to design a database for storing hierarchical structure ?

using single table

Create a table like this

database

CREATE TABLE `category` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) default NULL,
`descr` text,
`parent` int(11) default NOT NULL,
PRIMARY KEY  (`id`)
)

This table containing fields id,name,description and parent.Here all are familiar fields except parent.
Parent field is used to store the id of parent item . So that we can select the sub category by querying the database

with parent==id .

First upon we have to display main category by querying parent==’0′,
Then sub category by querying parent==1 or some thing like that
I think this information useful .

Regards,
Arun Raj R
Kadampanad

Categories: Mysql, database Tags: , , , ,

Videos, Slideshows and Podcasts by Cincopa Wordpress Plugin