小编Gil*_*lko的帖子

SQLSTATE [42S22]:未找到列:1054未知列 - Laravel

我正在使用Laravel框架.

我有2个表(用户和成员).当我想登录时,我收到错误消息:

SQLSTATE [42S22]:未找到列:1054'where子句'中的未知列'user_email'(SQL:select*from memberswhere user_email=?limit 1)(Bindings:array(0 =>'test@hotmail.com',))

表用户

CREATE TABLE IF NOT EXISTS `festival_aid`.`users` (
  `user_id` BIGINT NOT NULL AUTO_INCREMENT,
  `user_email` VARCHAR(45) NOT NULL,
  `user_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `user_modified` TIMESTAMP NULL,
  `user_deleted` TIMESTAMP NULL,
  `user_lastlogin` TIMESTAMP NULL,
  `user_locked` TIMESTAMP NULL,
  PRIMARY KEY (`user_id`),
  UNIQUE INDEX `user_email_UNIQUE` (`user_email` ASC),
ENGINE = InnoDB;
Run Code Online (Sandbox Code Playgroud)

表成员

CREATE TABLE IF NOT EXISTS `festival_aid`.`members` (
  `member_id` BIGINT NOT NULL AUTO_INCREMENT,
  `member_password` CHAR(32) NOT NULL,
  `member_salt` CHAR(22) NOT NULL,
  `member_token` VARCHAR(128) NULL, …
Run Code Online (Sandbox Code Playgroud)

php sql where where-clause laravel

24
推荐指数
1
解决办法
13万
查看次数

是否可以在{{Form :: submit('')}}中放置一个bootstrap glyphicon - Laravel

我想改变这个:

{{ Form::submit('Delete this User', array('class' => 'btn btn-warning')) }}
Run Code Online (Sandbox Code Playgroud)

这样的事情:

{{ Form::submit('<i class="glyphicon glyphicon-delete"></i>', array('class' => '')) }}
Run Code Online (Sandbox Code Playgroud)

我知道第二个选项不正确,谁知道如何以正确的方式编写它?

php forms twitter-bootstrap laravel

23
推荐指数
1
解决办法
2万
查看次数

如何显示可读数组 - Laravel

写完之后:

Route::get('/', function()
{
    dd(User::all());
});
Run Code Online (Sandbox Code Playgroud)

刷新浏览器后,我得到一个不可读的数组.有没有办法以可读格式获取该数组?

php arrays function readable laravel

17
推荐指数
2
解决办法
9万
查看次数

使用powershell将文件名中每个单词的首字母大写

我想自动更改某些文件的名称.

使用此代码我将小写字母更改为大写:

get-childitem*.mp3 | foreach {if($ .Name -cne $ .Name.ToUpper()){ren $ .FullName $ .Name.ToUpper()}}

但我只希望每个单词的第一个字母都是大写的.

powershell cmd lowercase uppercase

16
推荐指数
2
解决办法
2万
查看次数

SQLSTATE [HY000]:常规错误:1005无法创建表 - Laravel 4

当我做php artisan migrate时,我收到此错误.我的迁移文件有什么问题吗?或者我的模型可能编码错误吗?但即使模型中存在问题,迁移也应该有效吗?

[Exception]                                                                  
  SQLSTATE[HY000]: General error: 1005 Can't create table 'festival_aid.#sql-  
  16643_2033' (errno: 150) (SQL: alter table `gigs` add constraint gigs_band_  
  id_foreign foreign key (`band_id`) references `bands` (`band_id`) on delete  
   cascade) (Bindings: array (                                                 
  ))

[PDOException]                                                               
  SQLSTATE[HY000]: General error: 1005 Can't create table 'festival_aid.#sql-  
  16643_2033' (errno: 150)
Run Code Online (Sandbox Code Playgroud)

演出迁移

public function up()
    {
        Schema::create('gigs', function($table)
        {
            $table->increments('gig_id');

            $table->dateTime('gig_startdate');

            $table->integer('band_id')->unsigned();
            $table->integer('stage_id')->unsigned();

            $table->foreign('band_id')
                ->references('band_id')->on('bands')
                ->onDelete('cascade');

            $table->foreign('stage_id')
                ->references('stage_id')->on('stages')
                ->onDelete('cascade');
        });

    public function down()
    {
        Schema::table('gigs', function($table)
        {
            Schema::drop('gigs');
            $table->dropForeign('gigs_band_id_foreign');
            $table->dropForeign('gigs_stage_id_foreign');
        });
    }
Run Code Online (Sandbox Code Playgroud)

乐队迁移 …

php migration laravel laravel-4

11
推荐指数
2
解决办法
3万
查看次数

cakePHP 3.0上传图片

我想在我的cakephp 3.0应用程序中上传图像.但我收到错误消息:

Notice (8): Undefined index: Images [APP/Controller/ImagesController.php, line 55]
Run Code Online (Sandbox Code Playgroud)

在cakePHP 3.0中是否已经有一些上传文件(一次多个文件)的例子?因为我只能找到cakePHP 2.x的例子!

我想我需要在ImagesTable.php中添加自定义验证方法?但我无法让它发挥作用.

ImagesTable

public function initialize(array $config) {
    $validator
       ->requirePresence('image_path', 'create')
       ->notEmpty('image_path')
       ->add('processImageUpload', 'custom', [
          'rule' => 'processImageUpload'
       ])
}

public function processImageUpload($check = array()) {
    if(!is_uploaded_file($check['image_path']['tmp_name'])){
       return FALSE;
    }
    if (!move_uploaded_file($check['image_path']['tmp_name'], WWW_ROOT . 'img' . DS . 'images' . DS . $check['image_path']['name'])){
        return FALSE;
    }
    $this->data[$this->alias]['image_path'] = 'images' . DS . $check['image_path']['name'];
    return TRUE;
}
Run Code Online (Sandbox Code Playgroud)

ImagesController

public function add()
    {
        $image = $this->Images->newEntity();
        if ($this->request->is('post')) {
            $image …
Run Code Online (Sandbox Code Playgroud)

php cakephp file-upload

9
推荐指数
2
解决办法
3万
查看次数

SQLSTATE [23000]:完整性约束违规:1452无法添加或更新子行:外键约束失败 - Laravel

我知道这个问题已被提出,但我仍然无法找到我做错的事.

我正在使用Laravel框架.

我有2个表(用户和位置).当我想创建一个用户时,我收到错误消息:

SQLSTATE [23000]:完整性约束违规:1452无法添加或更新子行:外键约束失败(festival_aid.users,CONSTRAINT fk_users_locations1FOREIGN KEY(location_id)REFERENCES locations(location_id)ON DELETE CASCADE ON UPDATE NO ACTION)(SQL:insert into users(user_id,, user_email)location_id)值(?,?,?))(Bindings:array(0 =>'1',1 =>'test @ hotmail.com',2 =>'1',))

表用户

CREATE TABLE IF NOT EXISTS `festival_aid`.`users` (
  `user_id` BIGINT NOT NULL AUTO_INCREMENT,
  `user_email` VARCHAR(45) NOT NULL,
  `user_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `user_modified` TIMESTAMP NULL,
  `user_deleted` TIMESTAMP NULL,
  `user_lastlogin` TIMESTAMP NULL,
  `user_locked` TIMESTAMP NULL,
  `location_id` BIGINT NOT NULL,
  PRIMARY KEY (`user_id`), …
Run Code Online (Sandbox Code Playgroud)

php mysql constraints foreign-keys laravel

7
推荐指数
1
解决办法
4万
查看次数

Laravel 和谷歌地图:foreach 纬度/经度显示标记或地图

我有一个带有纬度和经度字段的表位置。

对于每个位置,我想要一张新地图(或者更好的新标记),它使用表格位置中的纬度和经度在地图上显示一个城市。

控制器的索引动作:

public function index()
    {
        $locations = Location::all();

        $locations->location_latitude = Input::get('location_latitude');
        $locations->location_longitude = Input::get('location_longitude');

        return View::make('forecasts.index')
            ->with('locations', $locations);
    }
Run Code Online (Sandbox Code Playgroud)

带有标记的谷歌地图:

function initialize() {

    var map_canvas = document.getElementById('map_canvas');

    var location = new google.maps.LatLng({{ $location->location_latitude }}, {{ $location->location_longitude }});

    var map_options = {
        center: location,
        zoom: 10,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }

    var map = new google.maps.Map(map_canvas, map_options)

    var marker = new google.maps.Marker({
        position: location,
        map: map,
    });

    marker.setMap(map);

  }

  google.maps.event.addDomListener(window, 'load', initialize);
Run Code Online (Sandbox Code Playgroud)

当我这样做时,它只显示最后插入的纬度/经度的城市:

@foreach($locations as $location)

   var location = new google.maps.LatLng({{ …
Run Code Online (Sandbox Code Playgroud)

javascript php foreach laravel laravel-4

5
推荐指数
1
解决办法
6916
查看次数

如何使用cakephp和twitter bootstrap在表单postlink中创建图标

这给了我想要的东西:

<?php echo $this->Html->link(
   $this->Html->tag('i', '', array('class' => 'glyphicon glyphicon-edit')) . " Edit",
   array('action' => 'edit', $comment['Comment']['comment_id']),
   array('class' => 'btn btn-mini', 'escape' => false)
); ?>
Run Code Online (Sandbox Code Playgroud)

但是当我创建一个Form postLink时,我不知道如何在它前面获取删除图标..

<?php echo $this->Form->postLink(
   $this->Html->tag('i', '', array('class' => 'glyphicon glyphicon-remove')) . " Delete",
   array('action' => 'delete', $comment['Comment']['comment_id']), null, __('Are you sure you want to delete # %s?', $comment['Comment']['comment_id']),
   array('class' => 'btn btn-mini', 'escape' => false)
); ?>
Run Code Online (Sandbox Code Playgroud)

它给了我 <i class="glyphicon glyphicon-remove"></i> Delete

forms tags cakephp twitter-bootstrap glyphicons

2
推荐指数
2
解决办法
6817
查看次数

缺少UserController :: edit()的参数2 - Laravel

我正在使用Laravel框架.

我有2个表(用户和人员).当我想编辑用户并同时编辑该人时,我收到错误消息:

缺少UserController :: edit()的参数2

表用户

CREATE TABLE IF NOT EXISTS `festival_aid`.`users` (
  `user_id` BIGINT NOT NULL AUTO_INCREMENT,
  `user_username` VARCHAR(45) NOT NULL,
  `user_email` VARCHAR(45) NOT NULL,
  `user_password` CHAR(32) NOT NULL,
  `user_salt` CHAR(32) NOT NULL,
  `user_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `user_modified` TIMESTAMP NULL,
  `user_deleted` TIMESTAMP NULL,
  `user_lastlogin` TIMESTAMP NULL,
  `user_locked` TIMESTAMP NULL,
  `user_token` VARCHAR(128) NULL,
  `user_confirmed` TIMESTAMP NULL,
  PRIMARY KEY (`user_id`, `person_id`),
  UNIQUE INDEX `user_email_UNIQUE` (`user_email` ASC),
  INDEX `fk_users_persons1_idx` (`person_id` ASC),
  CONSTRAINT `fk_users_persons1`
    FOREIGN KEY (`person_id`)
    REFERENCES `festival_aid`.`persons` (`person_id`)
    ON …
Run Code Online (Sandbox Code Playgroud)

php sql arguments edit laravel

1
推荐指数
1
解决办法
8282
查看次数