



many posts on the web page or blog. cause the page too long. because of that, content on the web need pagination.follow the tutorial for creating pagination:
on cake php pagination created with class component and class element.
Component:
place component on directotry /app/controller/component/pagination.php
Element:
place component on directotry /app/views/elements/pagination.thtml
helpers :
place component on directotry /app/views/helpers/pagination.php
if that file placed on the each directory. that class must be call from controller . this is a example call the class pagination on controller :
<?php
class PagesController extends AppController {
var $uses = array(‘Data’);
var $helpers = array(‘Html’,'Pagination’,'Javascript’,'Ajax’);
var $components = array(‘Paginations’);
var $paging;
$criteria=”";
list($order,$limit,$page) = $this->Paginations->init($criteria);
$result=$this->Data->findAll(null,null,null,$limit,$page);
$this->set(‘data’,$result);
?>
to download full code and real example, you can download script on this link DOWNLOAD




<?
$day=(mktime (0,0,0,6,17,2009) – mktime (0,0,0,5,1,2009))/86400;
$day=floor($day);
echo $day;
?>




Your app/config/database.php file is where your database configuration all takes place. A fresh install doesn’t have a database.php, so you’ll need to make a copy of database.php.default. Once you’ve made a copy and renamed it you’ll see the following:
Example 4.1. app/config/database.php
var $default = array('driver' => 'mysql',
'connect' => 'mysql_connect',
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'project_name',
'prefix' => '');
Replace the information provided by default with the database connection information for your application.
One note about the prefix key: the string you enter there will be prepended to any SQL call that Cake makes to your database when working with tables. You define it here once so you don’t have to specify it in other places. It also allows you to follow Cake’s table naming conventions if you’re on a host that only gives you a single database. Note: for HABTM join tables, you only add the prefix once: prefix_apples_bananas, not prefix_apples_prefix_bananas.
CakePHP supports the following database drivers:
The ‘connect’ key in the $default connection allows you to specify whether or not the database connection will be treated as persistent or not. Read the comments in the database.php.default file for help on specifying connection types for your database setup.
Your database tables should also follow the following conventions:
You’ll also notice that there is a $test connection setting included in the database.php file. Fill out this configuration (or add other similarly formatted configurations) and use it in your application by placing something like:
var $useDbConfig = 'test';
Inside one of your models. You can add any number of additional connection settings in this manner.




In order use CakePHP you must first have a server that has all the required libraries and programs to run CakePHP:
There are a few ways you can secure a copy of CakePHP: getting a stable release from CakeForge, grabbing a nightly build, or getting a fresh version of code from SVN.
To download a stable version of code, check out the files section of the CakePHP project at CakeForge by going to http://cakeforge.org/projects/cakephp/.
To grab a nightly, download one from http://cakephp.org/downloads/index/nightly. These nightly releases are stable, and often include the bug fixes between stable releases.
To grab a fresh copy from our SVN repository, use your favorite SVN client and connect to https://svn.cakephp.org/repo/trunk/cake/ and choose the version you’re after.
Now that you’ve downloaded the most recent release, place that compressed package on your web server in the webroot. Now you need to unpack the CakePHP package. There are two ways to do this, using a development setup, which allows you to easily view many CakePHP applications under a single domain, or using the production setup, which allows for a single CakePHP application on the domain.
Configuring Apache and mod_rewrite
While CakePHP is built to work with mod_rewrite out of the box, we’ve noticed that a few users struggle with getting everything to play nicely on their systems. Here are a few things you might try to get it running correctly:
RewriteBase /~myusername/“.php_flag session.trans_id off” to the .htaccess file at the root of your installation as well.Make Sure It’s Working
Alright, lets see this baby in action. Depending on which setup you used, you should point your browser to http://www.example.com or http://www.example.com/cake. At this point, you’ll be presented with CakePHP’s default home, and a message that tells you the status of your current database connection.
Congratulations! You are ready to create your first Cake-based application.




sometimes we need to read a file for the program. now I can discuss about that. php have default function to read the file on directory.
Example 1. dir() example
Please note the fashion in which dir()‘s return value is checked in the example below. We are explicitly testing whether the return value is identical to (equal to and of the same type as–see Comparison Operators for more information) FALSE since otherwise, any directory entry whose name evaluates to FALSE will stop the loop.
<?php |
The above example will output something similar to:
Handle: Resource id #2 Path: /etc/php5 . .. apache cgi cli |
hope that helps….




The Extensible Markup Language (XML) is a markup language much like HTML or SGML. This is recommended by the World Wide Web Consortium and available as an open standard.
XML is a portable, open source language that allows programmers to develop applications that can be read by other applications, regardless of operating system and/or developmental language.
preg_match_all( “/\<Envelope\>(.*?)\<\/Envelope\>/s”,
$xml, $bookblocks );
foreach( $bookblocks[1] as $block )
{
preg_match_all( “/\<Filename\>(.*?)\<\/Filename\>/”,
$block, $author );
preg_match_all( “/\<MessageType\>(.*?)\<\/MessageType\>/”,
$block, $title );
preg_match_all( “/\<Owner\>(.*?)\<\/Owner\>/”,
$block, $publisher );
echo( $title[1][0].” – “.$author[1][0].” – “.
$publisher[1][0].”\n” );
}
?>




Routes Configuration
“Routing” is a pared-down pure-PHP mod_rewrite-alike that can map URLs to controller/action/params and back. It was added to Cake to make pretty URLs more configurable and to divorce us from the mod_rewrite requirement. Using mod_rewrite, however, will make your address bar look much more tidy.
Routes are individual rules that map matching URLs to specific controllers and actions. Routes are configured in the app/config/routes.php file. They are set-up like this:
Example 4.2. Route Pattern
<?php
$Route->connect (
'URL',
array('controller'=>'controllername',
'action'=>'actionname', 'firstparam')
);
?>
Where:
Any parameters following firstparam will also be passed as parameters to the controller action.
The following example joins all the urls in /blog to the BlogController. The default action will be BlogController::index().
Example 4.3. Route Example
<?php
$Route->connect ('/blog/:action/*', array('controller'=>'Blog', 'action'=>'index'));
?>
A URL like /blog/history/05/june can then be handled like this:
Example 4.4. Route Handling in a Controller
<?php
class BlogController extends AppController
{
function history ($year, $month=null)
{
// .. Display appropriate content
}
}
?>
The ‘history’ from the URL was matched by :action from the Blog’s route. URL elements matched by * are passed to the active controller’s handling method as parameters, hence the $year and $month. Called with URL /blog/history/05, history() would only be passed one parameter, 05.
The following example is a default CakePHP route used to set up a route for PagesController::display(‘home’). Home is a view which can be overridden by creating the file /app/views/pages/home.thtml.
Example 4.5. Setting the Default Route
<?php
$Route->connect ('/', array('controller'=>'Pages', 'action'=>'display', 'home'));
?>
resource: manual cakephp download




Your app/config/database.php file is where your database configuration all takes place. A fresh install doesn’t have a database.php, so you’ll need to make a copy of database.php.default. Once you’ve made a copy and renamed it you’ll see the following:
Example 4.1. app/config/database.php
var $default = array('driver' => 'mysql',
'connect' => 'mysql_connect',
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'project_name',
'prefix' => '');
Replace the information provided by default with the database connection information for your application.
One note about the prefix key: the string you enter there will be prepended to any SQL call that Cake makes to your database when working with tables. You define it here once so you don’t have to specify it in other places. It also allows you to follow Cake’s table naming conventions if you’re on a host that only gives you a single database. Note: for HABTM join tables, you only add the prefix once: prefix_apples_bananas, not prefix_apples_prefix_bananas.
CakePHP supports the following database drivers:
The ‘connect’ key in the $default connection allows you to specify whether or not the database connection will be treated as persistent or not. Read the comments in the database.php.default file for help on specifying connection types for your database setup.
Your database tables should also follow the following conventions:
You’ll also notice that there is a $test connection setting included in the database.php file. Fill out this configuration (or add other similarly formatted configurations) and use it in your application by placing something like:
var $useDbConfig = 'test';
Inside one of your models. You can add any number of additional connection settings in this manner.




This AJAX method periodically performs an AJAX request and updates a container’s contents based on the response text.
Containers are specified by giving IDs of the HTML elements like division or paragraphs. See example below.
Callbacks are called at various points in the life-cycle of a request, and always feature the same list of arguments. They are passed to requesters right along with their other options.
Syntax:
new Ajax.PeriodicalUpdater(container, url[, options]);
Ajax.PeriodicalUpdater features all the Common Options and callbacks, plus those added by Ajax.Updater().
There are two more options specific to this method:
Option Description
frequency Default value is 2.
This is the minimum interval at which AJAX requests are made.
decay Default value is 1.
This controls the rate at which the request interval grows when the response is unchanged.
Return Value :
* Returns AJAX PeriodicalUpdater object.
Disabling and Enabling a PeriodicalUpdater :
You can pull the brake on a running PeriodicalUpdater by simply calling its stop method. If you wish to re-enable it later, just call its start method. Both take no argument.
Example:
Click start button to see how Current Time changes.
This example may not work in IE.
Here is the content of timer.cgi script:
#!/usr/bin/perl
print “Content-type: text/html\n\n”;
$datetime = localtime;
print $datetime;
print ”
“;




multiple uplaod file dengan cakephp
multi file upload dengan cakephp. multi upload digunakan untuk meng upload beberapa file secara bersamaan. untuk download script silahkan klik di sini untuk DOWNLOAD


More Options ...
Categories
Tag Cloud
Blog RSS
Comments RSS


Void « Default
Life
Earth
Wind
Water
Fire
Light 