我正在尝试在cakephp上配置MS-MSQL数据库(不是mysql).
我的Wampserver在我的笔记本电脑上是2.2e-php5.4.3-httpd2.2.22-mysql5.5.24-32b(这是windows x64-bit.
我已经邀请这两个dll来运行sql server
extension = php_sqlsrv_54_ts.dll
extension = php_pdo_sqlsrv_54_ts.dll
我在运行cakephp 1.3时遇到了这两个错误
Strict standards: Redefining already defined constructor for class Object in C:\wamp\www\project\cake\libs\object.php on line 54<br/>
Strict standards: Non-static method Configure::getInstance() should not be called statically in C:\wamp\www\project\cake\bootstrap.php on line 38
Run Code Online (Sandbox Code Playgroud)
我也安装WampServer2.1e-x32它不起作用:(
任何帮助PLZ
我编写了一个函数,可以给我一个月的所有天,不包括周末。一切正常,但是当我想获取12月的日子时,Date对象将返回下周的01 Jan,并且该函数将返回一个空数组。
请帮忙。
function getDaysInMonth(month, year) {
var date = new Date(year, month-1, 1);
var days = [];
while (date.getMonth() === month) {
// Exclude weekends
var tmpDate = new Date(date);
var weekDay = tmpDate.getDay(); // week day
var day = tmpDate.getDate(); // day
if (weekDay !== 1 && weekDay !== 2) {
days.push(day);
}
date.setDate(date.getDate() + 1);
}
return days;
}
alert(getDaysInMonth(month, year))
Run Code Online (Sandbox Code Playgroud) 我有一个查询如下,但我只需要某些字段而不是所有字段.我已将autoFields设置为false,但查询仍返回所有字段.
$tenancies = $this
->find('all')
->autoFields(false)
->select([
'Tenancy.id', 'Tenancy.created', 'Tenancy.stage',
'Properties.id', 'Properties.address1', 'Properties.postcode',
'Tenants.stage',
])
->contain('Properties', function(\Cake\ORM\Query $query) {
return $query->where([
'Properties.active' => 1
]);
})
->contain(['Tenants'])
->leftJoinWith('Tenants', function(\Cake\ORM\Query $query) {
return $query
->autoFields(false)
->select([
'id', 'stage'
])
->where([
'Tenants.active' => 1
]);
})
->where([
'Tenancy.active' => 1,
$conditions
])
->order([
'Tenancy.created' => 'DESC',
'Tenants.tenancy_id'
])
->group(['Properties.id'])
->autoFields(false);
return $tenancies;
Run Code Online (Sandbox Code Playgroud)
打印=>
object(App\Model\Entity\Tenancy) {
'id' => (int) 3934,
'created' => object(Cake\I18n\FrozenTime) {
'time' => '2016-03-20T18:25:20+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false …
Run Code Online (Sandbox Code Playgroud) 我在HTML中有以下几行:
<header class="title">
<h3>Billing Address</h3>
</header>
<address>
<p>Address</p>
</address>
Run Code Online (Sandbox Code Playgroud)
我想将它们包装在一个新的div
使用jQuery 之间,因为我无法访问HTML.
如果我使用.before()
和.after()
,它不起作用
$('header').before('<div="new-div">');
$('address').after('</div>');
Run Code Online (Sandbox Code Playgroud)
我曾尝试与.wrap()
和.append()
,但也不起作用.
结果应该是:
<div class="new-div">
<header class="title">
<h3>Billing Address</h3>
</header>
<address>
<p> Address </p>
</address>
</div>
Run Code Online (Sandbox Code Playgroud)
谢谢!
我是码头工人的新人。我使用 VueJs2 构建了一个与外部 API 交互的应用程序。我想在 docker 上运行该应用程序。
这是我的 docker-compose.yml 文件
version: '3'
services:
ew_cp:
image: vuejs_img
container_name: ew_cp
build:
context: .
dockerfile: Dockerfile
volumes:
- '.:/app'
- '/app/node_modules'
ports:
- '8080:8080'
Run Code Online (Sandbox Code Playgroud)
这是我的 Dockerfile:
FROM node:14.17.0-alpine as develop-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
RUN yarn install
COPY . .
EXPOSE 8080
CMD ["node"]
Run Code Online (Sandbox Code Playgroud)
这是我运行的用于将图像构建为容器的构建命令。
docker-compose up -d
Run Code Online (Sandbox Code Playgroud)
图像和容器正在构建,没有错误,但是当我运行容器时,它立即停止。所以容器没有运行。DockerFile 和 compose 文件设置是否正确?
我正在制作实用程序类,它将提供帮助操作字符串的一般方法.我可能还想要一个用于数组,数学函数等.这些是组件吗?供应商?我可以将它们变成某种供应商包吗?
如何打印ORM查询
$query = $articles->find('all')->contain(['Comments']);
Run Code Online (Sandbox Code Playgroud)
例如print =>
SELECT * FROM comments WHERE article_id IN (comments);
Run Code Online (Sandbox Code Playgroud) 我想使用自定义字段创建下拉列表,但我的列表查询将id字段附加到查询中。如何仅显示查询中的选定字段。
$this->loadModel('CardTypes');
$cardTypes = $this->CardTypes->find('list')->select(['code', 'name']);
Run Code Online (Sandbox Code Playgroud)
在我看来
$this->Form->select('card_type_id', $cardTypes, [ 'default' => 'DELTA']);
Run Code Online (Sandbox Code Playgroud) 如何设置电子邮件布局和模板
$email = new Email('default');
$email->setFrom($from)
->setTo('test@gmail.com')
->setSubject('Test email')
->setEmailFormat('html')
->viewBuilder()->setLayout('my-email-layout')
->setViewVars([
'name' => Alex
])
->send('My message');
Run Code Online (Sandbox Code Playgroud)
电子邮件打印
[protected] _viewBuilder => object(Cake\View\ViewBuilder) {
[protected] _templatePath => null
[protected] _template => ''
[protected] _plugin => null
[protected] _theme => null
[protected] _layout => 'default'
[protected] _autoLayout => null
[protected] _layoutPath => null
[protected] _name => null
[protected] _className => 'Cake\View\View'
[protected] _options => []
[protected] _helpers => [
(int) 0 => 'Html'
]
[protected] _vars => []
}
Run Code Online (Sandbox Code Playgroud) 有没有办法通过元素名称获得输入类型
<form name="formQuestionnaire">
<input name="age" type="radio" id="age-1" />
<input name="age" type="radio" id="age-2" />
</form>
document.forms['formQuestionnaire'].elements['age']
Run Code Online (Sandbox Code Playgroud)
返回收音机/复选框/文字
此功能正在处理OR条件.我需要这个来处理AND条件.任何帮助:
$ands = array();
foreach ($array_training_id as $id) {
$ands[] = array('TrainingsUser.training_id' => $id);
}
$conditions = array('AND' => $ands);
$users = $this->TrainingsUser->find('all', array('conditions' => $conditions));
Run Code Online (Sandbox Code Playgroud)
我想写一个查询AND条件,如下所示:
SELECT user_id FROM trainings_users WHERE training_id = 172 AND training_id = 174
Run Code Online (Sandbox Code Playgroud)
获取第一个ID时,此查询正在运行.
表说明:我有3个表Training - User - Training_users ... training_users表有traing_id和user_id我想要的东西是这样的东西: SELECT user_id FROM Training_users WHERE training_id = 172 AND training_id = 174
...它甚至在SqlMyadmin中也不起作用
当我给training_id 172和training_id 174时我需要的是它必须仅返回用户150
设置状态为空时返回“0”的最短方法是什么,否则返回值。
$value['status'] = null;
$STATUSES = array(
0 => 'Pending',
1 => 'Accepted',
2 => 'Suspended',
3 => 'Rejected',
4 => 'Waiting list',
5 => 'Terminated',
9 => 'Application in Progress'
);
$status = $STATUSES[$value['status']];
echo $status;
Run Code Online (Sandbox Code Playgroud)
我可以使用empty()函数来检查值是否为“null”,但我想知道是否有更聪明的方法。
我正在寻找这样的本机函数。
$status = $STATUSES[ valueToZiro( $value['status'] )];
function valueToZiro($val){
return empty($val)?0:$val;
}
Run Code Online (Sandbox Code Playgroud) cakephp ×7
javascript ×3
cakephp-1.3 ×2
cakephp-3.x ×2
cakephp-2.0 ×1
cakephp-2.1 ×1
cakephp-2.x ×1
cakephp-3.2 ×1
cakephp-3.7 ×1
docker ×1
html ×1
jquery ×1
php ×1
vue.js ×1