我正在使用json-schema并且只想允许在此文件中声明的属性通过验证.例如,如果用户在其json对象中传递"name"属性,则该模式将失败,因为此处未将"name"列为属性.
是否有一些类似于"必需"的功能只允许列出的属性通过?
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Accounting Resource - Add Item",
"type": "object",
"properties": {
"itemNumber": {
"type":"string",
"minimum": 3
},
"title": {
"type":"string",
"minimum": 5
},
"description": {
"type":"string",
"minimum": 5
}
},
"required": [
"itemNumber",
"title",
"description"
]
}
Run Code Online (Sandbox Code Playgroud)
}
我试图在laravel中加载一个模型,但只返回某些列.我不希望呈现整个急切的加载表.
public function car()
{
return $this->hasOne('Car', 'id')->get(['emailid','name']);
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
log.ERROR:异常'Symfony\Component\Debug\Exception\FatalErrorException',带有消息'调用未定义的方法Illuminate\Database\Eloquent\Collection :: getAndResetWheres()'
我正在尝试使用supervisord运行java进程并且正在获取:
couldn't exec /var/application/start_tester: ENOEXEC
Run Code Online (Sandbox Code Playgroud)
start_tester的内容是:
java -Duser.dir=/var/application/ -cp /var/application/application.jar:/var/application/toepoke.jar com.application.Application
Run Code Online (Sandbox Code Playgroud)
当我从控制台运行脚本时,应用程序按预期运行.这是我的主管配置
[program:application_tester]
directory=/var/application
command=/var/application/start_tester ; the program (relative uses PATH, can take args)
log_stdout=true ; if true, log program stdout (default true)
log_stderr=true ; if true, log program stderr (def false)
logfile=/var/log/application_tester.log
Run Code Online (Sandbox Code Playgroud)
当我从控制台运行脚本时,这是输出:
[root@monitor application]# ./start_tester
20131009 203657: application starting up.
20131009 203657 (33): version 2.2.3
Run Code Online (Sandbox Code Playgroud) 我试图弄清楚如何设置required我的json-schema对象数组.必需属性在对象上工作正常,而不是数组.
这是我的json架构的项目部分:
"items": {
"type": "array",
"properties": {
"item_id": {"type" : "number"},
"quantity": {"type": "number"},
"price": {"type" : "decimal"},
"title": {"type": "string"},
"description": {"type": "string"}
},
"required": ["item_id","quantity","price","title","description"],
"additionalProperties" : false
}
Run Code Online (Sandbox Code Playgroud)
这是我发送的json数组.json验证应该失败,因为我没有在这些项目中传递描述.
"items": [
{
"item_id": 1,
"quantity": 3,
"price": 30,
"title": "item1 new name"
},
{
"item_id": 1,
"quantity": 16,
"price": 30,
"title": "Test Two"
}
]
Run Code Online (Sandbox Code Playgroud) 我正在尝试运行单元测试并在安装过程中创建数据库.出于某种原因,我收到了错误Unknown database 'coretest'.如果我手动创建数据库并运行测试,那么我得到Can't create database 'coretest'; database exists.
drop database语句现在只适用于create database.
这是我的setUP和tearDown方法:
class TestCase extends Illuminate\Foundation\Testing\TestCase {
/**
* Default preparation for each test
*/
public function setUp() {
parent::setUp();
DB::statement('create database coretest;');
Artisan::call('migrate');
$this->seed();
Mail::pretend(true);
}
public function tearDown() {
parent::tearDown();
DB::statement('drop database coretest;');
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用supervisord将节点应用程序作为服务运行.
如果我去/ opt/uptime并运行:
node app.js
Run Code Online (Sandbox Code Playgroud)
我的应用程序从前台开始.一旦我按下ctrl + c它就会死掉..正如预期的那样.
我已经安装了supervisor并将其添加到配置中:
[program:uptime]
command=/usr/local/bin/node app.js
directory=/opt/uptime/
Run Code Online (Sandbox Code Playgroud)
我可以成功启动主管,但如果我做supervisorctl状态,我得到:
uptime BACKOFF Exited too quickly (process log may have details)
Run Code Online (Sandbox Code Playgroud)
以下是日志文件:
/var/log/supervisor/supervisord.log
2013-04-25 09:37:10,854 CRIT Supervisor running as root (no user in config file)
2013-04-25 09:37:10,866 INFO /var/tmp/supervisor.sock:Medusa (V1.1.1.1) started at Thu Apr 25 09:37:10 2013
Hostname: <unix domain socket>
Port:/var/tmp/supervisor.sock
2013-04-25 09:37:10,914 CRIT Running without any HTTP authentication checking
2013-04-25 09:37:10,915 INFO daemonizing the process
2013-04-25 09:37:10,917 INFO supervisord started with pid 28099
2013-04-25 09:37:10,918 …Run Code Online (Sandbox Code Playgroud) 我运行此脚本时收到以下消息:
警告:mysql_fetch_row()期望参数1是资源,第12行的/var/www/html/toolkit/routing.php中给出了字符串
我在mysql控制台中运行了查询,并打印出正确的行.不知道为什么我不能让它出现在PHP?
routing.php页面:
<?php
error_reporting(E_ALL);
////error_reporting(0);
ini_set('display_errors', 'On');
include("db/sbc_config.php");
include("db/mysql.class.php");
$db = new MySQL(true, DB_DATABASE_ROUTING, DB_SERVER, DB_USER , DB_PASS);
if ($db->Error()) $db->Kill();
$searchroute = "SELECT * FROM destination_route as d WHERE d.destPrefix='2146811'";
$result = mysql_fetch_row($searchroute);
echo $result;
?>
Run Code Online (Sandbox Code Playgroud)
sbc_config.php:
<?php
//database server
define('DB_SERVER', "10.10.1.146");
//database login name"
define('DB_USER', "user");
//database login password
define('DB_PASS', "pasword");
//database names
define('DB_DATABASE_ROUTING', "routing");
//smart to define your table names also
define('TABLE_DESTINATION_ROUTE', "destination_route");
?>
Run Code Online (Sandbox Code Playgroud) 我刚刚开始使用版本控制,我的头在旋转!我试图围绕树枝,结帐,合并和变基础.我相信这些都是愚蠢的问题,但我真的很感激一些帮助.
我的项目是PHP.我正在使用Aptana工作室为我的IDE,Bitbucket和SourceTree用于Git GUI.
所以我想我可能会对这应该如何工作有一个粗略的想法.请告诉我我错在哪里.
说我想添加一个新功能.我有一个主分支.在Aptana中,我可以右键单击文件→ 转到团队,然后创建一个新分支.我可以说出那个分支feature a1bc.我做了我的改变.
完成此功能和所有更改后,我单击Team → Commit,然后Team → Merge branch → master.这会将我的更改合并回主仓库.
这大致是我将如何进行功能添加等?如果随着时间的推移我有100多个功能,我该怎么办?我是否保留所有这些功能分支或在它们合并后删除它们?
我想以我所有代码都在src目录下的方式构建我的laravel应用程序.我的项目结构如下所示.我怎么能这样做才能打电话Route::get('accounting/item/{id}','AccountingItemController@getId')
我想避免将src下的每个模块添加到ClassLoader中.有没有办法告诉类加载器加载父目录src下的所有子目录?
app
app/src
app/src/accounting
app/src/accounting/controllers
app/src/accounting/models
app/src/accounting/repos
app/src/accounting/interfaces
app/src/job
app/src/job/controllers
app/src/job/models
app/src/job/repos
app/src/job/interfaces
Run Code Online (Sandbox Code Playgroud) 我写了一个脚本来返回数据库中的案例记录.当实际有两条记录时,我正在为我的mysql查询返回一条记录.这是我要回来的:
{ "cases": [ {"name":"Test Case for App","number":"3846"}] }
Run Code Online (Sandbox Code Playgroud)
我应该看到:
{ "cases": [ {"name":"Test Case for App","number": "2903"}, {"name":"Test Case 2","number": "2856"} ] }
Run Code Online (Sandbox Code Playgroud)
这是我的来源:
$sql = "select * from cases as c join contacts_cases as conc on c.id = conc.case_id where conc.contact_id = '1b360507'";
$query = mysql_query($sql);
// If we find a match, create an array of data, json_encode it and echo it out
if (mysql_num_rows($query) > 0)
{
$row = mysql_fetch_assoc($query);
$response = array(
'name' => $row['name'],
'number' …Run Code Online (Sandbox Code Playgroud) 我有一个脚本,echo的用户名插入到img src中.只要图像在目录中,这就很有用.如果文件存在,如何创建仅回显下面命令的if语句?如果它不存在则显示default.png
我尝试使用mod_rewrite并且运气不好..
<div class="contactphoto"><img src="contactphoto/<? echo ($note['user_name'] == "Support")? $note['first_name'].''.$note['last_name'] : $note['user_name'];?>.png"/></div>
Run Code Online (Sandbox Code Playgroud) php ×6
json ×3
laravel ×3
laravel-4 ×3
jsonschema ×2
mysql ×2
supervisord ×2
aptana ×1
bitbucket ×1
git ×1
javascript ×1
node.js ×1