如何使用Laravel Query Builder或Eloquent ORM在Laravel 3/4中检索原始执行的SQL查询?
例如,像这样:
DB::table('users')->where_status(1)->get();
Run Code Online (Sandbox Code Playgroud)
要么:
(posts (id, user_id, ...))
User::find(1)->posts->get();
Run Code Online (Sandbox Code Playgroud)
否则,至少我如何保存执行到laravel.log的所有查询?
我想在多个文件中查找单词,并且每个结果只返回一行,或者返回有限数量的字符(例如40~80个字符),而不是整行,默认情况下.
grep -sR 'wp-content' .
file_1.sql:3309:blog/wp-content
file_1.sql:3509:blog/wp-content
file_2.sql:309:blog/wp-content
Run Code Online (Sandbox Code Playgroud)
目前我看到以下内容:
grep -sR 'wp-content' .
file_1.sql:3309:blog/wp-content-Progressively predominate impactful systems without resource-leveling best practices. Uniquely maximize virtual channels and inexpensive results. Uniquely procrastinate multifunctional leadership skills without visionary systems. Continually redefine prospective deliverables without.
file_1.sql:3509:blog/wp-content-Progressively predominate impactful systems without resource-leveling best practices. Uniquely maximize virtual channels and inexpensive results. Uniquely procrastinate multifunctional leadership skills without visionary systems. Continually redefine prospective deliverables without.
file_2.sql:309:blog/wp-content-Progressively predominate impactful systems without resource-leveling best practices. Uniquely maximize virtual …Run Code Online (Sandbox Code Playgroud) Laravel 3/4中该表的正确表名是什么?
结构
image_projects(id,project_id,image,ext,size,created_at,updated_at,active)
image_projects
imageprojects
imageProjects
Run Code Online (Sandbox Code Playgroud)
而且,我如何创建模型?
app/models/image_projects.php
app/models/imageprojects.php
app/models/imageProjects.php
app/models/image/projects.php
app/models/projects/image.php
Run Code Online (Sandbox Code Playgroud) 我按照本教程:http://fideloper.com/post/41750468389/laravel-4-uber-quick-start-with-auth-guide?utm_source=nettuts&utm_medium=article&utm_content=api&utm_campaign=guest_author
本教程:http://laravelbook.com/laravel-database-seeding/
但是,当我尝试跑步时php artisan db:seed,没有任何反应.
我试试这个:
<?php
// app/database/seeds/groups.php
return array(
'table' => 'groups',
array(
'name' => 'Administrador',
'description' => '<p>Permissão total no sistema</p>',
'created_at' => new DateTime,
'updated_at' => new DateTime
),
array(
'name' => 'Moderadores',
'description' => '<p>Podem apenas postar e moderar comentários</p>',
'created_at' => new DateTime,
'updated_at' => new DateTime
)
);
Run Code Online (Sandbox Code Playgroud)
接下来:php artisan db:seed.
php artisan db:seed --env=local
Database seeded!
Run Code Online (Sandbox Code Playgroud)
但:
mysql> select * from groups; …Run Code Online (Sandbox Code Playgroud) 我第一次尝试使用CakePHP与作曲家,但我有一些问题.
我有这个composer.json:
{
"name": "example.com.br",
"repositories": [
{
"type": "pear",
"url": "http://pear.cakephp.org"
}
],
"config": {
"vendor-dir": "Vendor/"
},
"require": {
"php": ">=5.4",
"pear-cakephp/cakephp": ">=2.4.3",
"cakephp/debug_kit": "2.2.*",
"smottt/wideimage": "dev-master"
},
"extra": {
"installer-paths": {
"app/Plugin/DebugKit": ["cakephp/debug_kit"],
"app/Vendor/Wideimage": ["smottt/wideimage"]
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我跑步时composer install (or update) --prefer-dist,一切正常,除了smottt/wideimage.
此软件包正在安装在该/Vendor文件夹中/app/Vendor,因此,将忽略installer-paths.
当我忘了翻译的东西,地方项目的看法,我更改文件/app/Locale/por/LC_MESSAGES/default.po并将其发送回服务器.
但大多数情况下,这种"新译",需要几个小时来看待,总之:我刚刚发送的文件,清除缓存和浏览器的CakePHP,按F5,并... 没有任何反应.
是什么原因?
[编辑]
<?php echo $this->Form->input('Item.0.description', array('label' => false,
'class' => 'span12', 'div' => array('class' => 'span7'), 'rows' => 3,
'placeholder' => __('Type the description'))); ?>
Run Code Online (Sandbox Code Playgroud) 我需要一种方法来捕捉笔记本中打印的所有内容.
我有一个系统,在PHP中,有时我需要打印(php_printer)一些发票,但这需要大量的纸张.
打印在后台发送,没有任何弹出窗口供用户确认.
因此,每当我向打印机发送内容时,窗口(或任何应用程序)都会向我显示发送的内容; 或生成PDF.
问题是:如何在不更改打印机(驱动程序等)的情况下使用此"alternativa".因为,如果我这样做,我需要在2台打印机中进行测试,你知道我的意思.
这是我以前在windows或linux中打印的文件.我在Windows(公司的要求)开发,但在Linux服务器上发布.
要点: https ://gist.github.com/patrickmaciel/7673875
捕获每个打印文件并将其保存在PDF或某些驱动程序/应用程序中,以便不打印文件,而是在屏幕上显示给我(窗口).
开发操作系统(我的):Windows 7 (是的我知道,但我的员工只能使用Windows)
产品操作系统:CentOS
打印机:TM-T88IV AFU(爱普生)
我正在使用多个PHP版本(7和5.6)设置我的新笔记本,当完全编译PHP-7.0后,我在PHP-5.6编译过程中出现了tokenizer错误.
sudo mkdir /opt/sourcecd /opt/sourcesudo git clone https://github.com/php/php-src.gitcd php-srcsudo git checkout PHP-5.6.17sudo ./configure
--prefix=/opt/php-5.6
--with-pdo-pgsql
--with-zlib-dir
--with-freetype-dir
--enable-mbstring
--with-libxml-dir=/usr
--enable-soap
--enable-calendar
--with-curl
--with-mcrypt
--with-zlib
--with-gd
--with-pgsql
--disable-rpath
--enable-inline-optimization
--with-bz2
--with-zlib
--enable-sockets
--enable-sysvsem
--enable-sysvshm
--enable-pcntl
--enable-mbregex
--enable-exif
--enable-bcmath
--with-mhash
--enable-zip
--with-pcre-regex
--with-mysql
--with-pdo-mysql
--with-mysqli
--with-png-dir=/usr
--enable-gd-native-ttf
--with-openssl
--with-fpm-user=nginx
--with-fpm-group=nginx
--with-libdir=/lib/x86_64-linux-gnu
--enable-ftp
--with-imap
--with-imap-ssl
--with-kerberos
--with-gettext
--with-gd
--with-jpeg-dir=/usr/lib/
--enable-fpm/bin/bash /opt/source/php-src/libtool --silent --preserve-dup-deps --mode=compile cc -Iext/standard/ -I/opt/source/php-src/ext/standard/ -DPHP_ATOM_INC -I/opt/source/php-src/include -I/opt/source/php-src/main -I/opt/source/php-src …Run Code Online (Sandbox Code Playgroud) 我想在CakePHP 2.3中使用Smarty或Blade(Laravel)模板引擎.这是可能的?
如果有,怎么样?
如果你知道CakePHP的其他模板引擎,请告诉我.
我的问题是:
我在分支主机上工作了一个新功能,因为我忘了创建分支.
现在,我创建分支e使用:
git stash
git checkout new_branch;
git stash apply
Run Code Online (Sandbox Code Playgroud)
但是,当我回到master分支机构时,这些未提交和未跟踪的文件会留在master.
为什么?
正确的是add文件并在新分支中提交,或者我可以保持这种不受欢迎/未跟踪?