Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php #57

Open
uniquejava opened this issue Jul 4, 2016 · 1 comment
Open

php #57

uniquejava opened this issue Jul 4, 2016 · 1 comment

Comments

@uniquejava
Copy link
Owner

atom

确保安装了language-php插件,除此以外我还安装了apm install php-server

当前新增了如下有关php的snippets

'.text.html.php':
  'pre var_dump':
    'prefix': 'vd'
    'body': """
    echo "<pre>";
    var_dump($1);
    echo "</pre>";
    """
  'new entry in array':
    'prefix': 'entry'
    'body': '\'$1\' => $2'
  'new pdo':
    'prefix': 'pdo_new'
    'body': '$dbh = new PDO(\'mysql:host=localhost;dbname=php_course;port=8889;charset=utf8\', \'root\', \'$1\');'
  'pdo insert params':
    'prefix': 'pdo_insert_params'
    'body': """
    $stmt = $dbh->prepare('insert into posts(title, content) values(:title,:content)');
    $title = '阿甘正传2';
    $content = 'a very good movie, 值得拥有.';
    $stmt->bindParam(':title', $title);
    $stmt->bindParam(':content', $content);

    $stmt->execute();
    """
  'pdo insert ?':
    'prefix': 'pdo_insert'
    'body' : """
      $stmt = $dbh->prepare('insert into posts(title, content) values(?,?)');
      $title = '阿甘正传';
      $content = 'a very good movie, 值得拥有.';
      $stmt->bindParam(1, $title);
      $stmt->bindParam(2, $content);

      $stmt->execute();

    """
  'pdo insert array':
    'prefix': 'pdo_insert_array'
    'body' : """
      $stmt = $dbh->prepare('insert into posts(title, content) values(:title,:content)');
      $data = [
        'title' => '阿甘正传3',
        'content' => 'a very good movie, 值得拥有.'
      ];
      $stmt->execute($data);

    """
  'pdo select':
    'prefix': 'pdo_select'
    'body': """
    $stmt = $dbh->prepare(
      'select * from posts'
    );
    $stmt->execute();
    $stmt->setFetchMode(PDO::FETCH_ASSOC);

    while ($row = $stmt->fetch()) {
      echo "≪" . $row['title'] . '≫ ' . $row['content'] . '<br>';
    }
    """
@uniquejava
Copy link
Owner Author

TODO: http://ninghao.net/video/1859

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant