【使用like-laravel eloquent或原始MySQL查询进行反向查询】教程文章相关的互联网学习教程文章

php – SQLSTATE [HY000] [2003]无法连接到MySQL服务器’127.0.0.1′(61)错误Laravel 4.1【代码】

参见英文答案 > How to connect a Laravel app to MySQL using MAMP? 1个我在本地主机上收到Laravel 4.1的以下错误(使用MAMP)SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (61)它指向:/Applications/MAMP/htdocs/crowdsets/laravel-master/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php这是它指向的功能:public function createConn...

如何修复MySql:索引列大小太大(Laravel migrate)【代码】

我用一个安装了Debian,Nginx,PhpMyAdmin的流浪盒复制了一个项目.随着新项目,Laravel的php artisan migrate不再工作,我收到错误:[Illuminate\Database\QueryException] SQLSTATE[HY000]: General error: 1709 Index column size too large. The maximum column size is 767 bytes. (SQL: ...

mysql – Laravel Eloquent小组最近的记录【代码】

我正试图在桌面上获得单个客户的最新记录.例:ID Customer City Amount 1 Cust001 City1 2 2 Cust001 City2 3 3 Cust001 City1 1 4 Cust001 City2 1 5 Cust001 City2 3 6 Cust001 City3 1 7 Cust001 City3 1 8 Cust002 City1 2 9 Cust002 City1 1 10 Cust002 City2 3 11 Cust002 City1 2 12 Cust002 ...

PHP 7.0上的Laravel 5.4:PDO异常 – 找不到驱动程序(MySQL)【代码】

我在我的Ubuntu 14.04上有一个Laravel 5.4项目(VPS与Plesk 12.5.30).创建数据库并设置带有所需信息的.env文件后,我运行了php artisan migrate并抛出了异常:[Illuminate\Database\QueryException]could not find driver (SQL: select * from information_schema.tables where table_schema = pmaramaldb and table_name = migrations) [PDOException]could not find driver我的.env文件有:DB_CONNECTION=mysql DB_HOST=127.0.0.1 ...

mysql – Laravel Eloquent vs query builder – 为什么要使用eloquent来降低性能

我在Laravel查询构建器和eloquent之间进行了一些性能测试.使用各种sql语句(select-update-delete-insert),查询构建器的速度要快得多. 所以我的问题是:为什么有人使用Laravel Eloquent来反对普通查询构建器?解决方法:Eloquent是Laravel对Active Record模式的实现,它具有所有优点和缺点.当您以CRUD方式处理单个实体时,这是一个很好的解决方案 – 即,从数据库读取或创建新实体,然后保存或删除.您将从Eloquent的功能中受益匪浅,例如脏...

php – 如何使用mysql 8 docker测试laravel 5.6【代码】

由于mysql 8中的新哈希算法,我无法在gitlab中针对此mysql版本成功运行CI测试. 我相信这也适用于其他CI引擎. 让我们假设我的.gitlab-ci.yml就像那样简单:build:stage: buildimage: chilio/laravel-dusk-ci:stableservices:- mysql:8.0script:- cp .env.example .env- composer install- php artisan migrate这是我得到的错误:SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client我找到了不...

mysql – 使用Eloquent的Laravel和多次计数查询【代码】

我正在尝试优化我的代码,其中我在过去七天内生成统计数据. 目前我正在使用雄辩的和查询每天记录数据的计数,这使我在一个循环内进行7个单独的查询. 例:// loop for number of days for($i = 0; $i < $days; $i++){// some logic to set comparitive unix times$oldest = $newest - $dayDuration;// count number of objects between oldest time and newest time$counts[$i] = Object::where('objecttime','>',$oldest)->where('ob...

php – ORM for mysql now() – Laravel 4【代码】

我有以下sqlselect * from bids where deleted_at is null and publication_date <= now() and open_date >= now() 我想用ORM编写它$bids = Bid::where('publication_date','<=','now()')->where('open_date','>=','now()')->get();它不起作用,然后重写如下$bids=DB::select(DB::raw('select * from bids where deleted_at is null and publication_date <= now() and open_date >= now()'));如何在ORM上写上面的查询,我认为...

php – 将Mysql查询转换为Laravel 4 Eloquent【代码】

我想将此查询转换为Laravel 4 Eloquent.$query = SELECT * FROM standard_products WHERE frame_category like "%1%" OR frame_category like "%2%" OR frame_category like "%3%";我有一个数组$frame = Array([1]=1,[2]=2,[3]=3);需求: 使用$frame数组我希望在Laravel Eloquent中得到相同的结果 我的努力是:foreach ($frame as $val) {$match = Standard_product::orWhere('frame_category','like','%'.$val.'%');}$match = $m...

mysql – 重新排列Laravel迁移文件中的列【代码】

如何在Laravel迁移文件中为MySQL数据库重新排列列? 到目前为止,我有以下内容:$table->date('foo')->after('bar')->change();但是,它似乎没有重新安排列. 为什么不,我该如何解决这个问题呢?解决方法:在Laravel Schema API中看不到任何可以重新排列列的内容.您最好的选择是使用原始SQL语句,如下所示.DB::statement("ALTER TABLE table_name MODIFY COLUMN col_name col_definition AFTER another_col");

mysql – Laravel无法连接到数据库 – 迁移 – 错误2002【代码】

我现在已经搜索了几个小时,仍然无法找到它. 我得到2个错误,如果我将数据库主机用作’localhost’,我会收到此错误:[PDOException] SQLSTATE[HY000] [2002] No such file or directory 如果我将数据库主机更改为’127.0.0.1′,我会收到此错误:[PDOException] SQLSTATE[HY000] [2002] Connection refused我尝试过的事情: >改变运行apache / mysql服务器的位置(用...

php – Laravel:检查MySQL查询是否有结果【代码】

第一个Laravel项目.我有一个控制器功能,检查是否有条形码的记录.如果没有插入记录.如果是,则为计数添加一个.public function sellmode(Request $request){$barcode=$request->barcode;$test = DB::select('select count from sellmode where barcode = ?', [$barcode]);$row_cnt = mysqli_num_rows($test);if ($row_cnt == 0) {Debugbar::info('új sor');DB::insert('insert into sellmode (barcode, count) VALUES (?, ?)', [$bar...

php – Laravel 5.4迁移ENUM在MySQL中失败【代码】

当我尝试应用我的迁移时,我收到此错误:[Doctrine\DBAL\DBALException] Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.应用迁移,在数据库上创建枚举列,我得到错误,因此我无法执行nexts迁移,因为此迁移会抛出此错误. 在服务器中,我的MySQL版本为5.7.17 这是我的迁移代码:class AddDocumentUsersTable extends Migration {/*** Run the migrations.** @return void*/public f...

mysql – 如何在Laravel Eloquent中使用MIN和MAX sql查询【代码】

我想在同一条线上使用min和max laravel,这是可能的吗?Appointmentsetting::where('Day','=',1) ->whereIn('PersonID', function ($query) {$query->select('p.id')->from('users as p')->join('appointmentsettings as aps', 'aps.PersonID', '=', 'p.id')->where('p.active', '=', 1)->where('aps.CompanyID', '=', 1)->orWhereIn('aps.PersonID', function ($query2) {$query2->select('cps.user_id')->from('companypersonstru...

phpstudy将mysql升级到mysql8,mysql8配置,mysql8加密方式更改,mysql8遇到laravel报错解决【代码】

一,phpstudy升级mysql到mysql8(新的phpstudy8已经是mysql8了) 1,下载mysql8 2,将原来的mysql文件夹重命名,并执行 mysqld --remove 3,将新的mysql8放进去并命名MySQL 4,编辑my.ini,如下供借鉴 # power by php中文网 2017 www.php.cn 官网下载最新版 [client] port=3306 [mysql] default-character-set=utf8 [mysqld] port=3306 basedir="D:/apps/phpstudy2018/PHPTutorial/MySQL/" datadir="D:/apps/phpstudy2018/PHPTutoria...

LIKE - 相关标签