Sep
27
2008
0

Smarty — Good Template engine for PHP

Just when i wrote my previous post, I needed it myself already. Had to install ezSQL onto my new project.
When installing this i figured that it would be nice to use a template engine. Since i have experience with Smarty I downloaded it and installed it also to my new project.

What is Smarty?

Smarty is a very easy to use template engine. I’ll show you some examples below:

// At regular sites you would use this code:
<?php
 
$row = array("1","2","3","4");
 
foreach ($row as $newrow) {
   echo('this is no. '.$newrow);
}
?>
//in Smarty you would write this: 
// At index file
<?php
$smarty->assign('row',array("1","2","3","4"));
?>
//At template file:
 
{foreach from=$row item=item}
    This is no. {$item}
{/foreach}

It looks like a lot of extra work, but you can use ths array everywhere. Also Smarty forces you to use functions. And with the assign key you can enter a function in it.

This makes Smarty very usefull for OOP applications. And always easy to extend without a lot of nonsense.

I recon you don’t know a lot about this Smarty. But I’ll show you new examples in the near future.

Information and download at www.smarty.net

Written by Rene Pot in: Sugestions | Tags: , , , , ,
Sep
26
2008
1

Work with function ezSQL

Since a couple of weeks i work with ezSQL. And i came to the conclusion this function is much more usefull than the normal mySQL tags. It is very easy in ezSQL to get 1 row, or multiple. And the output is in a simple array!

I’ll just show you with some code below.

<?php
 
// First connect to database
 
$db = new ezSQL_mysql(DB_USER,DB_PASSWORD,DB_NAME,DB_HOST); 
 
// Get items from database
 
$playlists = $db->get_results("SELECT * FROM playlist ORDER BY id DESC");
 
// And now just print it.
 
foreach ($playlists as $item) {
    echo('Name is: '. $item->name .'.');
}
 
?>

As you can see it works very easy with a database. Besides get_results ezSQL has some other functions.

<?php
 
$row = $db->get_row(" SELECT * FROM playlist WHERE id=5"); // Just get 1 row
 
$var = $db->get_var(" SELECT name FROM playlist WHERE id=5"); // Just get 1 variable
 
?>

Ofcourse there are many other features in ezSQL. I would say try it for yourself! Go get it at http://www.woyano.com/jv/ezsql

Thanks for reading this post! I hope it has been of good use.

Examples and documentation can be found Here

Written by Rene Pot in: Sugestions | Tags: , , ,
Sep
25
2008
0

Introduce myself

First of all i would like to introduce myself to you.

I am Rene Pot, 20 years old and I already have approximately 4 years experience with PHP. 

I run my own company Topener and work for Syntraks / 1080dots. (www.1080dots.com) At 1080dots i’m developing the back-end for the play-list system. 

I also have some own projects running, so plenty of work to do!

Written by Rene Pot in: general | Tags: ,

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes