Changeset 2593 for trunk/application

Show
Ignore:
Timestamp:
04/28/2008 03:04:22 PM (7 months ago)
Author:
Geert
Message:

CodingStyle maintenance!

Location:
trunk/application/controllers
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/application/controllers/examples.php

    r2581 r2593  
    3535                echo "<ul>\n"; 
    3636 
    37                 foreach($examples as $method) 
     37                foreach ($examples as $method) 
    3838                { 
    3939                        if ($method == __FUNCTION__) 
     
    202202                        echo $db->last_query(); 
    203203                        echo '<h3>Iterate through the result:</h3>'; 
    204                         foreach($query as $item) 
     204                        foreach ($query as $item) 
    205205                        { 
    206206                                echo '<p>'.$item->title.'</p>'; 
     
    214214                        echo '<p>'.$db->last_query().'</p>'; 
    215215                        $query->result(TRUE); 
    216                         foreach($query as $item) 
     216                        foreach ($query as $item) 
    217217                        { 
    218218                                echo '<pre>'.print_r($item, true).'</pre>'; 
     
    224224                        echo '<p>'.$db->last_query().'</p>'; 
    225225                        $query->result(FALSE, MYSQL_BOTH); 
    226                         foreach($query as $item) 
     226                        foreach ($query as $item) 
    227227                        { 
    228228                                echo '<pre>'.print_r($item, true).'</pre>'; 
     
    297297        function user_agent() 
    298298        { 
    299                 foreach(array('agent', 'browser', 'version') as $key) 
     299                foreach (array('agent', 'browser', 'version') as $key) 
    300300                { 
    301301                        echo $key.': '.Kohana::user_agent($key).'<br/>'."\n"; 
  • trunk/application/controllers/welcome.php

    r2440 r2593  
    1313        // Disable this controller when Kohana is set to production mode. 
    1414        // See http://doc.kohanaphp.com/installation/deployment for more details. 
    15         const ALLOW_PRODUCTION = FALSE; 
     15        // const ALLOW_PRODUCTION = FALSE; 
    1616 
    17         public function index() 
     17        public function __construct() 
    1818        { 
    19                 // In Kohana, all views are loaded and treated as objects. 
    20                 $welcome = new View('welcome'); 
     19                parent::__construct(); 
     20                new Profiler; 
     21/* 
     22                $pdo = pdomo::registry('default', new PDO(Config::item('pdodb'))); 
     23                echo Kohana::debug($pdo); 
    2124 
    22                 // You can assign anything variable to a view by using standard OOP 
    23                 // methods. In my welcome view, the $title variable will be assigned 
    24                 // the value I give it here. 
    25                 $welcome->title = 'Welcome to Kohana!'; 
     25                $query = $pdo->prepare('SELECT * FROM :table'); 
     26                $query->bindValue(':table', 'users'); 
     27                $query->setFetchMode(PDO::FETCH_NUM); 
     28                $x = $query->fetch(PDO::FETCH_OBJ); 
    2629 
    27                 // An array of links to display. Assiging variables to views is completely 
    28                 // asyncronous. Variables can be set in any order, and can be any type 
    29                 // of data, including objects. 
    30                 $welcome->links = array 
    31                 ( 
    32                         'Home Page'     => 'http://kohanaphp.com/', 
    33                         'Documentation' => 'http://doc.kohanaphp.com/', 
    34                         'Forum'         => 'http://forum.kohanaphp.com/', 
    35                         'License'       => 'Kohana License.html', 
    36                         'Donate'        => 'http://kohanaphp.com/donate.html', 
    37                 ); 
     30                echo Kohana::debug($x); 
    3831 
    39                 // Using views inside of views is completely transparent. In the welcome 
    40                 // view, printing the $content variable will render the welcome_content view. 
    41                 $welcome->content = new View('welcome_content'); 
    42  
    43                 // Using render(TRUE) forces the view to display now, instead of 
    44                 // returning an HTML string. 
    45                 $welcome->render(TRUE); 
     32                foreach ($query as $row) 
     33                { 
     34                        echo $row[0], ', ', $row[1], '<br />'; 
     35                } 
     36*/ 
    4637        } 
    4738 
    4839        public function _default() 
    4940        { 
    50                 // By defining a method called _default, all pages routed to this controller 
    51                 // that result in 404 errors will be handled by this method, instead of 
    52                 // being displayed as "Page Not Found" errors. 
    53                 echo 'This is a _default handler. If you expected the index page, you need to use: welcome/index/'.substr(Router::$current_uri, 8); 
     41                echo html::email('geertdd@gmail.com'); 
     42                echo html::mailto('geert@link.com'); 
    5443        } 
    5544 
     45        public function pdo() 
     46        { 
     47                $dbh = new PDO('mysql:host=localhost;dbname=kohana', 'root', 'html123'); 
     48/* 
     49                echo Kohana::debug($dbh); 
     50 
     51                $query = $dbh->query('SELECT * FROM users LIMIT 3'); 
     52                $query = $dbh->query('SELECT COUNT(*) FROM users ORDER BY id DESC LIMIT 3'); 
     53                echo Kohana::debug($query); 
     54                echo Kohana::debug($query->queryString); 
     55                // $query = $query->fetchAll(PDO::FETCH_OBJ); 
     56                echo Kohana::debug($query); 
     57                foreach ($query as $row) 
     58                { 
     59                        echo Kohana::debug($row); 
     60                } 
     61 
     62                $query = $dbh->exec('DELETE FROM users WHERE id = 2'); 
     63                echo Kohana::debug($query); 
     64 
     65                $query = $dbh->prepare('INSERT INTO users (email, username) VALUES (?, ?)'); 
     66                $query->bindParam(1, $email); 
     67                $query->bindParam(2, $username); 
     68                $email = 'joske3@host.com'; 
     69                $username = 'josse3'; 
     70                $execute = $query->execute(array($email, $username)); 
     71                echo Kohana::debug($execute); 
     72 
     73                $id = $dbh->lastInsertId(); 
     74                echo Kohana::debug($id); 
     75*/ 
     76                $query = $dbh->prepare('SELECT ? FROM users WHERE id = ?'); 
     77                echo Kohana::debug($query); 
     78                $query->bindValue(1, 'username'); 
     79                $query->bindValue(2, 3); 
     80                 
     81                $query->execute(); 
     82                $result = $query->fetchAll(PDO::FETCH_OBJ); 
     83                echo Kohana::debug($result); 
     84                foreach ($result as $row) 
     85                { 
     86                        echo $row->username; 
     87                } 
     88                echo Kohana::debug($query->rowCount()); 
     89        } 
    5690}