what is alternative of R::$f->now() in redbean 4.X - redbean

in redbean v.3.x there is option to select date from db like R::$f->now() what is alternative of this in redbean v.4.x

You can use R::getCell('SELECT now()'); to run any sql commands, to get current time you just need to call R::isoDate(); or R::isoDateTime();

Related

Is there any way to get the syntax of an SQL statement when using SQLPlus?

I have an exam using SQLPlus and sometimes I don't remember the exact syntax of SQL statements, so I was wondering if there is any way to get some nice inline help from inside SQLPlus.
For instance, say I forgot how to use INSERT INTO, and I want some reminder like this:
INSERT INTO table-name (column-names)
VALUES (values)
Is this possible?
I tried HELP command but none of that seems to suits my needs.
I Googled it with no success.
No. SQL is a standardized language (at least ANSI SQL) and SQLPlus "just" uses that syntax, so it's not covered by internal help. Internal help lists only SQLPlus specific commands (ex. SET, CONNECT, SPOOL).
It is possible to workaround that in some way, but very limited. You can call dbms_metadata.get_ddl function for some existing object. Some of those DDLs could have statements you are intrested in. For example - you'd like to see select statement - then you could call dbms_metadata.get_ddl for some existing view:
select dbms_metadata.get_ddl('VIEW', 'USER_TABLES', 'SYS')
from dual;
Be aware - it works only for Oracle 11G and lower, in the newest one SYS objects are not accessible in that way (I'm not sure about Oracle 12.1).
The more interesting are tiggers, procedures, functions, and packages. You cannot use dbms_metadata to get DDLs of packages owned by SYS, but maybe you can connect to some sample schemas like HR (Human Resources), AD (Academic), SH (Sales History).
In HR schema there is stored procedure ADD_JOB_HISTORY, which has inside insert statement, so it looks like that:
select dbms_metadata.get_ddl('PROCEDURE', 'ADD_JOB_HISTORY')
from dual;
CREATE OR REPLACE EDITIONABLE PROCEDURE "HR"."ADD_JOB_HISTORY"
( p_emp_id job_history.employee_id%type
, p_start_date job_history.start_date%type
, p_end_date job_history.end_date%type
, p_job_id job_history.job_id%type
, p_department_id job_history.department_id%type
)
IS
BEGIN
INSERT INTO job_history (employee_id, start_date, end_date,
job_id, department_id)
VALUES(p_emp_id, p_start_date, p_end_date, p_job_id, p_department_id);
END add_job_history;
There are better ways and better tools to achieve your goal - see below.
Are you allowed to use SQL Developer instead of SQLPlus? SQL Developer has nice feature to drag-and-drop table icon into worksheet, then you will be nicely prompted to choose what kind of example statement you are looking for (SELECT, INSERT, UPDATE etc.) - after choosing one you will get sample statement.
But the best way is just open in browser Database SQL Language Reference:
https://docs.oracle.com/database/121/SQLRF/toc.htm

How to get numbers of code line change in TFS?

I'm looking for a way in TFS, I need to get the numbers of Code line change for individual developer between 2 dates, do you think it is doable via TFS?
Any help is appreciate, thanks!
Look in the TFS data warehouse. There is a FactCodeChurn table that should contain the data you're after.
You can use below SQL query statement:
SELECT TeamProjectProjectNodeName
,checkedinbyname
,SUM([LinesAdded]) AS
,SUM([LinesModified]) AS
,SUM([LinesAdded]+[LinesModified]) AS
,CONVERT(VARCHAR(10), MIN(DateTime),120) AS
,CONVERT(VARCHAR(10),MAX(DateTime),120) AS
FROM [Tfs_Warehouse].[dbo].[CodeChurnView] WHERE TeamProjectProjectNodeName='xxx' AND ChangesetTitle NOT LIKE 'xx' AND FilenameFileExtension IN('.css','.cs','.aspx','.sql','js','.ascx') AND (LinesDeleted <>0 OR LinesModified<>0 OR FilenameFilePath LIKE '$/XX' AND FilenameFileExtension IN('.sql')) AND NetLinesAdded>=0 GROUP BY TeamProjectProjectNodeName, checkedinbyname
ORDER BY DESC
Note: You must have permission to access the Tfs_Warehouse database to execute the above statement.

sqlite_3 Last Insert rowid

I am working with an SQLite database on iOS, but I cannot figure out how to get the last inserted row ID. The sqlite3_last_insert_rowid() function only works with the current connection, so it is useless if i have just opened the database.
In C#, I am used to calling ExecuteScalar() with the SQL query SELECT last_insert_rowid(). Is there a way to do this using sqlite3?
No, sorry, you can only use it on the same db connection:
http://www.sqlite.org/c3ref/last_insert_rowid.html

Get value setted in GM_setValue from a custom Firefox extension

Do you know if a custom Firefox extension can read values setted calling GM_setValue() from a GraseMonkey user script?
These values exists in about:config, (enter "greasemonkey" in the filter).
Perhaps there exists an easier way to get them, though...
Since Greasemonkey 1.13 GM_setValue() uses an SQLite db to persist values.
This DB can be accessed directly (see https://github.com/greasemonkey/greasemonkey/blob/master/modules/miscapis.js).

Is there any way to output the sql generated by a propel select in symfony?

I want to output the query generated by a symfony propel select for testing purposes. Is there any way to do this? I know I can use the sf_debug bar, but sometimes I need to see the statement in a situation where the sf_debug bar hasn't loaded yet, or isn't going to load at all.
Timmow is right that there is a Criteria::toString() method, but it's not the magic _toString() method that's automatically called when the object is referenced as a string.
If you want to see the SQL you have to explicitly call Criteria::toString().
$c = new Criteria();
// HERE: add criteria
// what's it do?
echo $c->toString(); // oh, that's what it does
Propel Criteria objects have a toString method, so you should simply be able to echo / var_dump / log to a file the criteria object you are interested in
It also might be helpful to take a look at Day 6 of the Jobeet Tutorial, Debugging Propel generated SQL. If you're in the debug environment, the raw queries are output to the log files. Not 100% sure as I use Doctrine.
You'll get the generated SQL statement that way after you've build the criteria :
$params= array();
$resulting_sql_statement = BasePeer::createSelectSql($criteria,$params);

Resources