redbean


RedBeanPHP - R::isoDateTime() - How to set timezone?

回眸只為那壹抹淺笑 提交于 2020-01-05 04:19:07
问题 There is a convenience function in RedBeanPHP ORM for ceating dates. $time = R::isoDateTime(); How can I set a time zone? The default function does not return the time of the machine on which RB is running on. 回答1: It appears from reading the source code, that R::isoDateTime() is just a convenience method. It simply calls the PHP time() function, then formats the result as a string using the date function. I didn't test it, but in theory - the date_default_timezone_set function should work.

How to implement priorities in SQL (postgres)

ぃ、小莉子 提交于 2019-12-31 06:52:05
问题 I'm writing some software that requires storing items in a database, the items need to have a 'priority' so we end up with ID | Name | Priority --------+--------------+---------- 1 | Pear | 4 2 | Apple | 2 3 | Orange | 1 4 | Banana | 3 So now, the top priority fruit is the Orange, then Apple then Banana then Pear. Now, I want to make Pear the number one priority so Pear, Orange, Apple, Banana. The table will look like: ID | Name | Priority --------+--------------+---------- 1 | Pear | 1 2 |

Using json_encode on objects in PHP (regardless of scope)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-27 17:00:36
问题 I'm trying to output lists of objects as json and would like to know if there's a way to make objects usable to json_encode ? The code I've got looks something like $related = $user->getRelatedUsers(); echo json_encode($related); Right now, I'm just iterating through the array of users and individually exporting them into arrays for json_encode to turn into usable json for me. I've already tried making the objects iterable, but json_encode just seems to skip them anyway. edit : here's the var

How to bulk insert with RedBeanPhp?

て烟熏妆下的殇ゞ 提交于 2019-12-23 09:33:15
问题 I was hoping for an example on how to bulk insert new "beans" in readbeanphp without looping over each instance. It shows an example creating and saving a beans here: http://redbeanphp.com/manual/create_a_bean It makes mention of storeAll($beans) method, but I am unsure exactly how I am suppose to format the data in $beans. I have tried googling for this and can not find anything related to bulk inserts. Maybe I have searched for the wrong terms. I am new to this ORM, any help with would

Is RedBean ORM able to create unique keys?

好久不见. 提交于 2019-12-21 05:09:08
问题 I'd like RedBean to create unique keys/indexes when generating the schema. The following code does- opposed to how I understand the documentation- not do this: R::setup('sqlite:rss_loader.db3'); $bean = R::findOne(IMG); if (!$bean->id) { $bean = R::dispense(IMG); $bean->setMeta("buildcommand.unique.0", array('url')); $bean->url = 'text'; R::store($bean); $bean->wipe(); R::freeze(); //no more schema changes! } What is happening in sqlite ist this: create table img (id integer primary key

Incorrect Data Format using Redbean PHP and dates - stored as VARCHAR(255)

家住魔仙堡 提交于 2019-12-13 08:27:52
问题 I'm connecting to MySQL with Redbean PHP and both date and date_deux come through as varchar(255). I assume I'm in fluid mode by default. How can I correct the problem? require('rb.php'); R::setup('my connection info',$username, $password); $book = R::dispense( 'book' ); $book->title = 'Boost development with RedBeanPHP'; $book->author = 'Charles Xavier'; $book->date = '2010-07-08'; $book->date_deux = '08/07/2010'; $id = R::store($book); echo $id; UPDATE: I guess specifically I'm looking

Pre-packaged Redbean fetches only one (last) row

混江龙づ霸主 提交于 2019-12-11 15:04:13
问题 I'd like to use the pre-packaged one-file Redbean 1.3 ORM from http://www.redbeanphp.com. When I try to get a result this way.. require_once ('redbean/rb.php'); require_once ('config.php'); R::setup('mysql:host='.MYSQL_HOST.';dbname=mydb', MYSQL_USER, MYSQL_PASS); $test = R::find('function', ' ID < 10 '); foreach ($test as $val) echo $val->Class.'<br>'; the output is as follows: Notice: Undefined index: id in rb.php on line 3686 Notice: Undefined index: id in rb.php on line 3686 Notice:

Batch insert into mysql by RedBean

人走茶凉 提交于 2019-12-11 12:47:32
问题 How to run following sql by RedBean? INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9); Should I use loop or RedBean support batch insert? 回答1: Creator of RedBeanPHP here. This is not supported by RedBeanPHP. You will have to use plain old SQL for this. 回答2: What about sample logic?: $list = array(1, 2, 3, 4, 5, 6, 7, 8, 9); $beans = R::dispense('table', count($list)); for($i=0; $i<count($list)/3; $i++) { $beans[$i]->a = $list[$i*3+1]; $beans[$i]->b = $list[$i*3+2]; $beans[$i]->c =

Not saving property of a php-redbean to database

时间秒杀一切 提交于 2019-12-11 02:13:56
问题 I'm using Redbean as an ORM for my php-application. Every user (employee in this situation), has to have a password in order to login, and I thought i'd generate one for them, so they don't have to type it in the form. Obviously, this means they all have to have a salt, and the only password stored should be the hash value of the actual password. Because of that I have to send the password to the user (otherwise they won't know it :D), and thus have to have it as a property of the object,

Empty or truncate table with RedBean PHP?

徘徊边缘 提交于 2019-12-10 18:24:20
问题 I'm using RedBean PHP for testing purposes and I like it very much, however I have no idea how I can truncate a table. I can fetch all the beans and delete them, but that seems cumbersome. 回答1: In RedBean 1.3 you can use R::wipe($type) to truncate a table. 回答2: RedBean is just an ORM tool (AFAIK) so if your back-end database is SQL based, you can simply do an SQL statement like: TRUNCATE TABLE yourTable; To execute queries directly via RedBean The Adapter The adapter is the class that

工具导航Map