Friday, June 5, 2015

Re: Migrations cake v.1.3 -> v.3.x

This is all you need in your Table:
https://github.com/dereuromark/cakephp-tools/blob/cake3/src/Model/Table/Table.php#L132


Am Freitag, 5. Juni 2015 09:16:44 UTC+2 schrieb InYan:

Please suggest if there is an analogue of cakephp3
 ------------------
Continuing this question, please tell how to cakephp3 implement such a code: $this->Model->query("TRUNCATE TABLE models;")

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

stocker un tableau avec l'option serialize() cakephp

Bonjour,

est ce que quelqu'un peut m aidé pour stocker un tableau qui contient une colonne date par mois et des lignes de type d'absence , j'utilise cakephp , j'ai réussie de stocker une seul colonne, mais j'arrive pas de stocker tout le tableau . merci

voila mon code de mon controleur 

public function edit($id = null) {
if (!$this->Clas->exists($id)) {
throw new NotFoundException(__('Invalid clas'));
}
if ($this->request->is(array('post', 'put'))) {
if ($this->Clas->saveAll($this->request->data)) {
$_POST['data']['Clas']= mysql_escape_string(serialize($_POST['data']['Clas']));
        var_dump($_POST['data']['Clas']);
$this->Session->setFlash(__('The clas has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
debug($this->request->data);
$this->Session->setFlash(__('The clas could not be saved. Please, try again.'));
}
} else {
$options = array('conditions' => array('Clas.' . $this->Clas->primaryKey => $id));
$this->request->data = $this->Clas->find('first', $options);
}
}

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Migrations cake v.1.3 -> v.3.x

Please suggest if there is an analogue of cakephp3
 ------------------
Continuing this question, please tell how to cakephp3 implement such a code: $this->Model->query("TRUNCATE TABLE models;")
I found such a code, but how to use it - do not know http://api.cakephp.org/3.0/source-class-Cake.Database.Schema.BaseSchema.html#_truncateTableSql

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: How to write a query | cakephp 3.x

I use classic php:
$link = mysql_connect("localhost", $db, $psw) or die("No connect MySQL.");
mysql_select_db
($db) or die("No connect DB.");


if(!empty($word_1)){$word_1 = "kw LIKE '%{$word_1}%'" ;}else{$word_1 = null ;}
if(!empty($word_2)){$word_2 = " AND kw LIKE '%{$word_2}%'" ;}else{$word_2 = null ;}
if(!empty($word_3)){$word_3 = " AND kw LIKE '%{$word_3}%'" ;}else{$word_3 = null ;}
if(!empty($word_4)){$word_4 = ") OR (kw LIKE '%{$word_4}%'" ;}else{$word_4 = null ;}
if(!empty($word_5)){$word_5 = " AND kw LIKE '%{$word_5}%'" ;}else{$word_5 = null ;}
if(!empty($word_6)){$word_6 = " AND kw LIKE '%{$word_6}%'" ;}else{$word_6 = null ;}
if(!empty($word_7)){$word_7 = ") AND NOT (kw LIKE '%{$word_7}%'" ;}else{$word_7 = null ;}
if(!empty($word_8)){$word_8 = " OR kw LIKE '%{$word_8}%'" ;}else{$word_8 = null ;}
if(!empty($word_9)){$word_9 = " OR kw LIKE '%{$word_9}%'" ;}else{$word_9 = null ;}


$query
= "SELECT * FROM keywords WHERE
 (({$word_1}{$word_2}{$word_3}{$word_4}{$word_5}{$word_6}){$word_7}{$word_8}{$word_9}) order by frequency desc"
;


$res  
= mysql_query($query);
while($row = mysql_fetch_array($res)){$result[$row['id']]['kw'] = $row['kw'];
                                      $result
[$row['id']]['id'] = $row['id'];
                                      $result
[$row['id']]['frequency'] = $row['frequency'];}


mysql_close
($link);

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Thursday, June 4, 2015

Special table/column name

Hi,

It seems there are some special table/column name will have advantage for cakephp, like the column "name" will be show rather than id. Th username and password also.

My question is, where can I found the information about the special name ?

Thank you.

Leo   

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: CakePHP 2.4 Auth->login() always return TRUE ... ?

I have same issue! Code seems almost seems.
Can anyone please help me out???plz

-- appcontroller

<?php

// app/Controller/AppController.php
class AppController extends Controller {
 public $components = array(
        'Session',
        'Auth' => array(
            'loginRedirect' => array(
                'controller' => 'users',
                'action' => 'index'
            ),
            'loginAction' => array('controller' => 'users', 'action' => 'login'),

            'logoutRedirect' => array(
                'controller' => 'users',
                'action' => 'login',                
            ),'authorize' => array('Controller')

        )
    );


    public function beforeFilter() {
      $this->Auth->allow('index', 'view','login');
    }
}
?>

login.ctp

<div class="users form">
<?php echo $this->Session->flash('auth'); ?>
<?php echo $this->Form->create('User'); ?>
    <fieldset>
        <legend>
            <?php echo __('Please enter your username and password'); ?>
        </legend>
        <?php echo $this->Form->input('username');
        echo $this->Form->input('password');
    ?>
    </fieldset>
<?php echo $this->Form->end(__('Login')); ?>
</div>

controller

public function login() { 
 
   if ($this->request->is('post')) {

    $this->Auth->authenticate['Form'] = array('fields' => array('username' => 'username'));
    //$this->request->data['User']['id'] = $this->User->id; 
    debug($this->request->data);
       if ($this->Auth->login()) {
        $this->Session->setFlash(sprintf("Welcome %s!", $this->Auth->user('username')));
           return $this->redirect($this->Auth->redirect());
       }
       $this->Session->setFlash(__('Invalid username or password, try again'));
   }
}

help plz

On Tuesday, 15 April 2014 17:16:56 UTC+5:30, MedAL wrote:
Hello,Iread the documentation to create a simple login form.each time I try to log in it returns true  always;

//UsersController
public function login() { 
if ($this->Auth->user()) {
            $this->redirect($this->Auth->redirect());
        }

   if ($this->request->is('post')) {

    $this->Auth->authenticate['Form'] = array('fields' => array('username' => 'username'));
    $this->request->data['User']['id'] = $this->User->id; 
    debug($this->request->data);
       if ($this->Auth->login($this->request->data['User'])) {
        $this->Session->setFlash(sprintf("Welcome %s!", $this->Auth->user('username')));
           return $this->redirect($this->Auth->redirect());
       }
       $this->Session->setFlash(__('Invalid username or password, try again'));
   }
}





//AppController
class AppController extends Controller {

public $components = array(
        'Session',
        'Auth' => array(
            'loginRedirect' => array(
                'controller' => 'Events',
                'action' => 'index'
            ),
            'loginAction' => array('controller' => 'Users', 'action' => 'login'),

            'logoutRedirect' => array(
                'controller' => 'Users',
                'action' => 'login',
                'home'
            ),'authorize' => array('Controller')

        )
    );

    public function beforeFilter() {
    //parent::beforeFilter();
        $this->Auth->allow('index', 'view','login');
        /* $this->Auth->authenticate = array(
   'Basic' => array('userModel' => 'User'),
   'Form' => array('userModel' => 'User')
);*/

    }



//login.ctp


<div class="users form">
<?php echo $this->Session->flash('auth'); ?>

<?php echo $this->Form->create('User'); ?>

    <fieldset>
        <legend>
            <?php echo __('Please enter your username and password'); ?>
        </legend>
        <?php echo $this->Form->input('username')
        echo $this->Form->input('password');
    ?>
    </fieldset>
<?php echo $this->Form->end(__('Login')); ?>
</div>

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

containable

Can we use containable in a model, Can anyone please suggest me on this ...

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.